Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ NOTE: FreeBSD builds will not be included for this release. There is a bug in an
upstream library preventing cross-compilation of the Grafana Cloud Agent for
this platform. FreeBSD builds will return in a future release.

# v0.9.1 (2021-01-04)

NOTE: FreeBSD builds will not be included for this release. There is a bug in an
upstream library preventing cross-compilation of the Grafana Cloud Agent for
this platform. FreeBSD builds will return in a future release.

- [ENHANCEMENT] agentctl will now be installed by the rpm and deb packages as
`grafana-agentctl`. (@rfratto)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Grafana Cloud Agent
<p align="center"><img src="docs/assets/logo_and_name.png" alt="Grafana Cloud Agent logo"></p>

Grafana Cloud Agent is an observability data collector optimized for sending
metrics and log data to [Grafana Cloud](https://grafana.com/products/cloud/).
Expand Down
4 changes: 4 additions & 0 deletions cmd/agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

// Adds version information
_ "github.com/grafana/agent/pkg/build"

"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/loki"
"github.com/grafana/agent/pkg/tempo"
Expand All @@ -23,6 +24,9 @@ import (

// Register Prometheus SD components
_ "github.com/prometheus/prometheus/discovery/install"

// Register integrations
_ "github.com/grafana/agent/pkg/integrations/install"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Grafana Cloud Agent
<p align="center"><img src="assets/logo_and_name.png" alt="Grafana Cloud Agent logo"></p>

The Grafana Cloud Agent is an observability data collector optimized for sending
metrics and log data to [Grafana Cloud](https://grafana.com/products/cloud/).
Expand Down
Binary file added docs/assets/logo_and_name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,7 @@ docker run \
-v "/proc:/host/proc:ro,rslave" \
-v /tmp/agent:/etc/agent \
-v /path/to/config.yaml:/etc/agent-config/agent.yaml \
grafana/agent:v0.9.0 \
grafana/agent:v0.9.1 \
--config.file=/etc/agent-config/agent.yaml
```

Expand Down Expand Up @@ -2066,7 +2066,7 @@ metadata:
name: agent
spec:
containers:
- image: grafana/agent:v0.9.0
- image: grafana/agent:v0.9.1
name: agent
args:
- --config.file=/etc/agent-config/agent.yaml
Expand Down Expand Up @@ -2332,7 +2332,7 @@ docker run \
-v "/proc:/proc:ro" \
-v /tmp/agent:/etc/agent \
-v /path/to/config.yaml:/etc/agent-config/agent.yaml \
grafana/agent:v0.9.0 \
grafana/agent:v0.9.1 \
--config.file=/etc/agent-config/agent.yaml
```

Expand All @@ -2349,7 +2349,7 @@ metadata:
name: agent
spec:
containers:
- image: grafana/agent:v0.9.0
- image: grafana/agent:v0.9.1
name: agent
args:
- --config.file=/etc/agent-config/agent.yaml
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Currently, there are five ways to install the agent:
### Docker Container

```
docker pull grafana/agent:v0.9.0
docker pull grafana/agent:v0.9.1
```

### Kubernetes Install Script
Expand Down Expand Up @@ -269,7 +269,7 @@ path of your Agent's YAML configuration file.
docker run \
-v /tmp/agent:/etc/agent \
-v /path/to/config.yaml:/etc/agent/agent.yaml \
grafana/agent:v0.9.0
grafana/agent:v0.9.1
```

### Locally
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ require (
google.golang.org/grpc v1.33.2
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
)

// Needed for Cortex's dependencies to work properly.
Expand Down
10 changes: 5 additions & 5 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (

// Config contains underlying configurations for the agent
type Config struct {
Server server.Config `yaml:"server"`
Prometheus prom.Config `yaml:"prometheus,omitempty"`
Loki loki.Config `yaml:"loki,omitempty"`
Integrations integrations.Config `yaml:"integrations"`
Tempo tempo.Config `yaml:"tempo,omitempty"`
Server server.Config `yaml:"server"`
Prometheus prom.Config `yaml:"prometheus,omitempty"`
Loki loki.Config `yaml:"loki,omitempty"`
Integrations integrations.ManagerConfig `yaml:"integrations"`
Tempo tempo.Config `yaml:"tempo,omitempty"`
}

// ApplyDefaults sets default values in the config
Expand Down
33 changes: 21 additions & 12 deletions pkg/integrations/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,44 @@ package agent
import (
"context"

"github.com/go-kit/kit/log"
"github.com/gorilla/mux"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/config"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

// Config controls the Agent integration.
type Config struct {
CommonConfig config.Common `yaml:",inline"`
Common config.Common `yaml:",inline"`
}

func (c *Config) Name() string {
return "agent"
}

func (c *Config) CommonConfig() config.Common {
return c.Common
}

// Enabled enables the Agent integration.
Enabled bool
func (c *Config) NewIntegration(_ log.Logger) (integrations.Integration, error) {
return New(c), nil
}

func init() {
integrations.RegisterIntegration(&Config{})
}

// Integration is the Agent integration. The Agent integration scrapes the
// Agent's own metrics.
type Integration struct {
c Config
c *Config
}

func New(c Config) *Integration {
func New(c *Config) *Integration {
return &Integration{c: c}
}

// CommonConfig satisfies Integration.CommonConfig.
func (i *Integration) CommonConfig() config.Common { return i.c.CommonConfig }

// Name satisfies Integration.Name.
func (i *Integration) Name() string { return "agent" }

// RegisterRoutes satisfies Integration.RegisterRoutes.
func (i *Integration) RegisterRoutes(r *mux.Router) error {
// Note that if the weaveworks common server is set to not register
Expand All @@ -48,7 +57,7 @@ func (i *Integration) RegisterRoutes(r *mux.Router) error {
// ScrapeConfigs satisfies Integration.ScrapeConfigs.
func (i *Integration) ScrapeConfigs() []config.ScrapeConfig {
return []config.ScrapeConfig{{
JobName: i.Name(),
JobName: i.c.Name(),
MetricsPath: "/metrics",
}}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Package common implements a bare-bones Integration that can be used by
// exporters that have no logic associated with them.
package common
package integrations

import (
"context"
Expand All @@ -18,28 +16,20 @@ import (
// collector.
type CollectorIntegration struct {
name string
cfg config.Common
c prometheus.Collector
includeExporterMetrics bool
}

// NewCollectorIntegration creates a basic integration that exposes metrics
// from a prometheus.Collector.
func NewCollectorIntegration(name string, cfg config.Common, c prometheus.Collector, includeExporterMetrics bool) *CollectorIntegration {
func NewCollectorIntegration(name string, c prometheus.Collector, includeExporterMetrics bool) *CollectorIntegration {
return &CollectorIntegration{
name: name,
cfg: cfg,
c: c,
includeExporterMetrics: includeExporterMetrics,
}
}

// CommonConfig satisfies Integration.CommonConfig.
func (i *CollectorIntegration) CommonConfig() config.Common { return i.cfg }

// Name satisfies Integration.Name.
func (i *CollectorIntegration) Name() string { return i.name }

// RegisterRoutes satisfies Integration.RegisterRoutes. The mux.Router provided
// here is expected to be a subrouter, where all registered paths will be
// registered within that subroute.
Expand Down Expand Up @@ -84,7 +74,7 @@ func (i *CollectorIntegration) handler() (http.Handler, error) {
// ScrapeConfigs satisfies Integration.ScrapeConfigs.
func (i *CollectorIntegration) ScrapeConfigs() []config.ScrapeConfig {
return []config.ScrapeConfig{{
JobName: i.Name(),
JobName: i.name,
MetricsPath: "/metrics",
}}
}
Expand Down
36 changes: 0 additions & 36 deletions pkg/integrations/common/integration.go

This file was deleted.

7 changes: 4 additions & 3 deletions pkg/integrations/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (
// Common is a set of common options shared by all integrations. It should be
// utilised by an integration's config by inlining the common options:
//
// type IntegrationConfig struct {
// Common config.Common `yaml:",inline"`
// }
// type IntegrationConfig struct {
// Common config.Common `yaml:",inline"`
// }
type Common struct {
Enabled bool `yaml:"enabled"`
ScrapeIntegration *bool `yaml:"scrape_integration"`
ScrapeInterval time.Duration `yaml:"scrape_interval"`
ScrapeTimeout time.Duration `yaml:"scrape_timeout"`
Expand Down
32 changes: 20 additions & 12 deletions pkg/integrations/consul_exporter/consul_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/grafana/agent/pkg/integrations/common"
"github.com/grafana/agent/pkg/integrations"
"github.com/grafana/agent/pkg/integrations/config"
consul_api "github.com/hashicorp/consul/api"
"github.com/prometheus/consul_exporter/pkg/exporter"
Expand All @@ -21,10 +21,7 @@ var DefaultConfig = Config{

// Config controls the consul_exporter integration.
type Config struct {
// Enabled enables the integration.
Enabled bool `yaml:"enabled"`

CommonConfig config.Common `yaml:",inline"`
Common config.Common `yaml:",inline"`

Server string `yaml:"server"`
CAFile string `yaml:"ca_file"`
Expand All @@ -50,9 +47,25 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
return unmarshal((*plain)(c))
}

func (c *Config) Name() string {
return "consul_exporter"
}

func (c *Config) CommonConfig() config.Common {
return c.Common
}

func (c *Config) NewIntegration(l log.Logger) (integrations.Integration, error) {
return New(l, c)
}

func init() {
integrations.RegisterIntegration(&Config{})
}

// New creates a new consul_exporter integration. The integration scrapes
// metrics from a consul process.
func New(log log.Logger, c Config) (common.Integration, error) {
func New(log log.Logger, c *Config) (integrations.Integration, error) {
var (
consulOpts = exporter.ConsulOpts{
CAFile: c.CAFile,
Expand All @@ -75,10 +88,5 @@ func New(log log.Logger, c Config) (common.Integration, error) {
return nil, err
}

return common.NewCollectorIntegration(
"consul_exporter",
c.CommonConfig,
e,
false,
), nil
return integrations.NewCollectorIntegration(c.Name(), e, false), nil
}
Loading