diff --git a/CHANGELOG.md b/CHANGELOG.md index 4794196b7d9a..e7c92b06a3c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Main (unreleased) - `otelcol.processor.probabilistic_sampler` samples logs and traces based on configuration options. (@mar4uk) - `remote.kubernetes.configmap` loads a configmap's data for use in other components (@captncraig) - `remote.kubernetes.secret` loads a secret's data for use in other components (@captncraig) + - `prometheus.exporter.agent` - scrape agent's metrics. (@hainenber) - Flow: allow the HTTP server to be configured with TLS in the config file using the new `http` config block. (@rfratto) diff --git a/component/all/all.go b/component/all/all.go index daa03dc4bd40..a13b1876438d 100644 --- a/component/all/all.go +++ b/component/all/all.go @@ -87,6 +87,7 @@ import ( _ "github.com/grafana/agent/component/otelcol/receiver/otlp" // Import otelcol.receiver.otlp _ "github.com/grafana/agent/component/otelcol/receiver/prometheus" // Import otelcol.receiver.prometheus _ "github.com/grafana/agent/component/otelcol/receiver/zipkin" // Import otelcol.receiver.zipkin + _ "github.com/grafana/agent/component/prometheus/exporter/agent" // Import prometheus.exporter.agent _ "github.com/grafana/agent/component/prometheus/exporter/apache" // Import prometheus.exporter.apache _ "github.com/grafana/agent/component/prometheus/exporter/azure" // Import prometheus.exporter.azure _ "github.com/grafana/agent/component/prometheus/exporter/blackbox" // Import prometheus.exporter.blackbox diff --git a/component/prometheus/exporter/agent/agent.go b/component/prometheus/exporter/agent/agent.go new file mode 100644 index 000000000000..dbbeba14aed0 --- /dev/null +++ b/component/prometheus/exporter/agent/agent.go @@ -0,0 +1,41 @@ +package agent + +import ( + "github.com/grafana/agent/component" + "github.com/grafana/agent/component/prometheus/exporter" + "github.com/grafana/agent/pkg/integrations" + "github.com/grafana/agent/pkg/integrations/agent" +) + +func init() { + component.Register(component.Registration{ + Name: "prometheus.exporter.agent", + Args: Arguments{}, + Exports: exporter.Exports{}, + NeedsServices: exporter.RequiredServices(), + Build: exporter.New(createExporter, "agent"), + }) +} + +func createExporter(opts component.Options, args component.Arguments) (integrations.Integration, error) { + a := args.(Arguments) + return a.Convert().NewIntegration(opts.Logger) +} + +// Arguments holds values which are used to configured the prometheus.exporter.agent component. +type Arguments struct{} + +// Exports holds the values exported by the prometheus.exporter.agent component. +type Exports struct{} + +// DefaultArguments defines the default settings +var DefaultArguments = Arguments{} + +// SetToDefault implements river.Defaulter +func (args *Arguments) SetToDefault() { + *args = DefaultArguments +} + +func (a *Arguments) Convert() *agent.Config { + return &agent.Config{} +} diff --git a/docs/sources/flow/reference/components/prometheus.exporter.agent.md b/docs/sources/flow/reference/components/prometheus.exporter.agent.md new file mode 100644 index 000000000000..174fece7fa2c --- /dev/null +++ b/docs/sources/flow/reference/components/prometheus.exporter.agent.md @@ -0,0 +1,68 @@ +--- +canonical: https://grafana.com/docs/agent/latest/flow/reference/components/prometheus.exporter.agent/ +title: prometheus.exporter.agen +--- + +# prometheus.exporter.agent +The `prometheus.exporter.agent` component collects and exposes metrics about the agent itself. + +## Usage + +```river +prometheus.exporter.agent "agent" { +} +``` + +## Arguments +`prometheus.exporter.agent` accepts no arguments. + +## Exported fields + +{{< docs/shared lookup="flow/reference/components/exporters-component-exports.md" source="agent" version="" >}} + +## Component health + +`prometheus.exporter.agent` is only reported as unhealthy if given +an invalid configuration. + +## Debug information + +`prometheus.exporter.agent` does not expose any component-specific +debug information. + +## Debug metrics + +`prometheus.exporter.agent` does not expose any component-specific +debug metrics. + +## Example + +This example uses a [`prometheus.scrape` component][scrape] to collect metrics +from `prometheus.exporter.agent`: + +```river +prometheus.exporter.agent "agent" {} + +// Configure a prometheus.scrape component to collect agent metrics. +prometheus.scrape "demo" { + targets = prometheus.exporter.agent.example.targets + forward_to = [prometheus.remote_write.demo.receiver] +} + +prometheus.remote_write "demo" { + endpoint { + url = PROMETHEUS_REMOTE_WRITE_URL + + basic_auth { + username = USERNAME + password = PASSWORD + } + } +} +``` +Replace the following: + - `PROMETHEUS_REMOTE_WRITE_URL`: The URL of the Prometheus remote_write-compatible server to send metrics to. + - `USERNAME`: The username to use for authentication to the remote_write API. + - `PASSWORD`: The password to use for authentication to the remote_write API. + +[scrape]: {{< relref "./prometheus.scrape.md" >}} \ No newline at end of file