-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(exporter): add Flow component for agent Integration (#5072)
* feat(exporter): add Flow component for agent's integration * doc(changelog): add new Feature entry * chore(comp/agent): correct comp name in comments * Update prometheus.exporter.agent.md Co-authored-by: Clayton Cornell <[email protected]> * feat(comp/agent): allow defining multiple blocks of agent's Prom exporter --------- Co-authored-by: Clayton Cornell <[email protected]>
- Loading branch information
1 parent
5373c94
commit f8e42f3
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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{} | ||
} |
68 changes: 68 additions & 0 deletions
68
docs/sources/flow/reference/components/prometheus.exporter.agent.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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="<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" >}} |