diff --git a/docs/sources/flow/reference/components/prometheus.exporter.catchpoint.md b/docs/sources/flow/reference/components/prometheus.exporter.catchpoint.md new file mode 100644 index 000000000000..2f1218efd45c --- /dev/null +++ b/docs/sources/flow/reference/components/prometheus.exporter.catchpoint.md @@ -0,0 +1,114 @@ +--- +aliases: + - /docs/grafana-cloud/agent/flow/reference/components/prometheus.exporter.catchpoint/ + - /docs/grafana-cloud/monitor-infrastructure/agent/flow/reference/components/prometheus.exporter.catchpoint/ + - /docs/grafana-cloud/monitor-infrastructure/integrations/agent/flow/reference/components/prometheus.exporter.catchpoint/ + - /docs/grafana-cloud/send-data/agent/flow/reference/components/prometheus.exporter.catchpoint/ +canonical: https://grafana.com/docs/agent/latest/flow/reference/components/prometheus.exporter.catchpoint/ +description: Learn about prometheus.exporter.catchpoint +title: prometheus.exporter.catchpoint +--- + +# prometheus.exporter.catchpoint + +The `prometheus.exporter.catchpoint` component embeds +[catchpoint_exporter](https://github.com/grafana/catchpoint-prometheus-exporter) for collecting statistics from a Catchpoint account. + +## Usage + +```river +prometheus.exporter.catchpoint "LABEL" { + port = PORT + verbosity_logging = VERBOSITY_LOGGING + webhook_path = WEBHOOK_PATH +} +``` + +## Arguments + +The following arguments can be used to configure the exporter's behavior. +Omitted fields take their default values. + +| Name | Type | Description | Default | Required | +| ------------------- | -------- | ----------------------------------------------------- | ----------------------- | -------- | +| `port` | `string` | The account to collect metrics for. | `"9090"` | yes | +| `verbosity_logging` | `bool` | The username for the user used when querying metrics. | `false` | yes | +| `webhook_path` | `string` | The password for the user used when querying metrics. | `"/catchpoint-webhook"` | yes | + +## Blocks + +The `prometheus.exporter.catchpoint` component does not support any blocks, and is configured +fully through arguments. + +## Exported fields + +{{< docs/shared lookup="flow/reference/components/exporter-component-exports.md" source="agent" version="" >}} + +## Component health + +`prometheus.exporter.catchpoint` is only reported as unhealthy if given +an invalid configuration. In those cases, exported fields retain their last +healthy values. + +## Debug information + +`prometheus.exporter.catchpoint` does not expose any component-specific +debug information. + +## Debug metrics + +`prometheus.exporter.catchpoint` does not expose any component-specific +debug metrics. + +## Example + +This example uses a [`prometheus.scrape` component][scrape] to collect metrics +from `prometheus.exporter.catchpoint`: + +```river +prometheus.exporter.catchpoint "example" { + port = "9090" + verbose_logging = false + webhook_path = "/catchpoint-webhook" +} + +// Configure a prometheus.scrape component to collect catchpoint metrics. +prometheus.scrape "demo" { + targets = prometheus.exporter.catchpoint.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" >}} + + + +## Compatible components + +`prometheus.exporter.catchpoint` has exports that can be consumed by the following components: + +- Components that consume [Targets](../../compatibility/#targets-consumers) + +{{< admonition type="note" >}} +Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. +Refer to the linked documentation for more details. +{{< /admonition >}} + + diff --git a/go.mod b/go.mod index dba9e3f36199..fc88eba35b2f 100644 --- a/go.mod +++ b/go.mod @@ -603,6 +603,7 @@ require ( github.com/dimchansky/utfbom v1.1.1 github.com/githubexporter/github-exporter v0.0.0-20231025122338-656e7dc33fe7 github.com/grafana/agent-remote-config v0.0.2 + github.com/grafana/catchpoint-prometheus-exporter v0.0.0-20240606062944-e55f3668661d github.com/grafana/jfr-parser/pprof v0.0.0-20240126072739-986e71dc0361 github.com/grafana/jsonparser v0.0.0-20240209175146-098958973a2d github.com/grafana/kafka_exporter v0.0.0-20240409084445-5e3488ad9f9a diff --git a/go.sum b/go.sum index 9cc619280431..e345d94a734a 100644 --- a/go.sum +++ b/go.sum @@ -1024,6 +1024,8 @@ github.com/grafana/agent-remote-config v0.0.2 h1:s3FKgVzfY5Ij+xG0wVKgVvtDrh/Bz0Z github.com/grafana/agent-remote-config v0.0.2/go.mod h1:amyG3pVNXKcMo+kNN46yhnAXAz/m/9Ew9MRf53n7XBg= github.com/grafana/cadvisor v0.0.0-20231110094609-5f7917925dea h1:Q5f5/nJJ0SbusZjA6F6XkJuHDbl2/PqdTGw6wHsuccA= github.com/grafana/cadvisor v0.0.0-20231110094609-5f7917925dea/go.mod h1:XjiOCFjmxXIWwauV5p39Mr2Yxlpyk72uKQH1UZvd4fQ= +github.com/grafana/catchpoint-prometheus-exporter v0.0.0-20240606062944-e55f3668661d h1:6sNPBwOokfCxAyateu7iLdtyWDUzaLLShPs7F4eTLfw= +github.com/grafana/catchpoint-prometheus-exporter v0.0.0-20240606062944-e55f3668661d/go.mod h1:aGPSALDAkw18nn8M7gumhM/MbJG+zgOA3jNWTwPYtLg= github.com/grafana/ckit v0.0.0-20230906125525-c046c99a5c04 h1:tG8Qxq4dN1WqakMmsPaxaH4+OQhYg5HVsarw5acLBX8= github.com/grafana/ckit v0.0.0-20230906125525-c046c99a5c04/go.mod h1:HOnDIbkxfvVlDM5FBujt0uawGLfdpdTeqE7fIwfBmQk= github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 h1:qhugDMdQ4Vp68H0tp/0iN17DM2ehRo1rLEdOFe/gB8I= diff --git a/internal/component/prometheus/exporter/catchpoint/catchpoint.go b/internal/component/prometheus/exporter/catchpoint/catchpoint.go index c180f8e84c8f..01409755474f 100644 --- a/internal/component/prometheus/exporter/catchpoint/catchpoint.go +++ b/internal/component/prometheus/exporter/catchpoint/catchpoint.go @@ -25,16 +25,16 @@ func createExporter(opts component.Options, args component.Arguments, defaultIns // DefaultArguments holds the default settings for the catchpoint exporter var DefaultArguments = Arguments{ - Verbose: false, - WebhookPath: "/catchpoint-webhook", - Port: "9090", + VerboseLogging: false, + WebhookPath: "/catchpoint-webhook", + Port: "9090", } // Arguments controls the catchpoint exporter. type Arguments struct { - Verbose bool `river:"verbose,attr"` - WebhookPath string `river:"webhookpath,attr"` - Port string `river:"port,attr"` + VerboseLogging bool `river:"verbose_logging,attr"` + WebhookPath string `river:"webhook_path,attr"` + Port string `river:"port,attr"` } // UnmarshalRiver implements River unmarshalling for Arguments. @@ -47,8 +47,8 @@ func (a *Arguments) UnmarshalRiver(f func(interface{}) error) error { func (a *Arguments) Convert() *catchpoint_exporter.Config { return &catchpoint_exporter.Config{ - Verbose: a.Verbose, - WebhookPath: a.WebhookPath, - Port: a.Port, + VerboseLogging: a.VerboseLogging, + WebhookPath: a.WebhookPath, + Port: a.Port, } } diff --git a/internal/component/prometheus/exporter/catchpoint/catchpoint_test.go b/internal/component/prometheus/exporter/catchpoint/catchpoint_test.go index 56bd78e34093..8179fa1baee4 100644 --- a/internal/component/prometheus/exporter/catchpoint/catchpoint_test.go +++ b/internal/component/prometheus/exporter/catchpoint/catchpoint_test.go @@ -10,9 +10,9 @@ import ( func TestRiverUnmarshal(t *testing.T) { riverConfig := ` - port = "3030" - verbose = true - webhookpath = "/nondefault-webhook-path" + port = "3030" + verbose_logging = true + webhook_path = "/nondefault-webhook-path" ` var args Arguments @@ -20,9 +20,9 @@ func TestRiverUnmarshal(t *testing.T) { require.NoError(t, err) expected := Arguments{ - Verbose: true, - Port: "3030", - WebhookPath: "/nondefault-webhook-path", + VerboseLogging: true, + Port: "3030", + WebhookPath: "/nondefault-webhook-path", } require.Equal(t, expected, args) @@ -30,9 +30,9 @@ func TestRiverUnmarshal(t *testing.T) { func TestConvert(t *testing.T) { riverConfig := ` - port = "3030" - verbose = true - webhookpath = "/nondefault-webhook-path" + port = "3030" + verbose_logging = true + webhook_path = "/nondefault-webhook-path" ` var args Arguments @@ -42,9 +42,9 @@ func TestConvert(t *testing.T) { res := args.Convert() expected := catchpoint_exporter.Config{ - Verbose: true, - Port: "3030", - WebhookPath: "/nondefault-webhook-path", + VerboseLogging: true, + Port: "3030", + WebhookPath: "/nondefault-webhook-path", } require.Equal(t, expected, *res) } diff --git a/static/integrations/catchpoint_exporter/catchpoint_exporter.go b/static/integrations/catchpoint_exporter/catchpoint_exporter.go index b51578b6fcd3..8013716004bc 100644 --- a/static/integrations/catchpoint_exporter/catchpoint_exporter.go +++ b/static/integrations/catchpoint_exporter/catchpoint_exporter.go @@ -5,28 +5,29 @@ import ( "github.com/grafana/agent/static/integrations" integrations_v2 "github.com/grafana/agent/static/integrations/v2" "github.com/grafana/agent/static/integrations/v2/metricsutils" - collector "github.com/grafana/catchpoint-prometheus-exporter" + + collector "github.com/grafana/catchpoint-prometheus-exporter/collector" ) -// DefaultConfig is the default config for the snowflake integration +// DefaultConfig is the default config for the catchpoint integration var DefaultConfig = Config{ - Verbose: false, - WebhookPath: "/catchpoint-webhook", - Port: "9090", + VerboseLogging: false, + WebhookPath: "/catchpoint-webhook", + Port: "9090", } -// Config is the configuration for the snowflake integration +// Config is the configuration for the catchpoint integration type Config struct { - Verbose bool `yaml:"verbose,omitempty"` - WebhookPath string `yaml:"webhookpath,omitempty"` - Port string `yaml:"port,omitempty"` + VerboseLogging bool `yaml:"verbose_logging,omitempty"` + WebhookPath string `yaml:"webhook_path,omitempty"` + Port string `yaml:"port,omitempty"` } func (c *Config) exporterConfig() *collector.Config { return &collector.Config{ - Verbose: c.Verbose, - WebhookPath: c.WebhookPath, - Port: string(c.Port), + VerboseLogging: c.VerboseLogging, + WebhookPath: c.WebhookPath, + Port: c.Port, } } @@ -57,10 +58,6 @@ func init() { func (c *Config) NewIntegration(l log.Logger) (integrations.Integration, error) { exporterConfig := c.exporterConfig() - if err := exporterConfig.Validate(); err != nil { - return nil, err - } - col := collector.NewCollector(l, exporterConfig) return integrations.NewCollectorIntegration( c.Name(), diff --git a/static/integrations/catchpoint_exporter/catchpoint_exporter_test.go b/static/integrations/catchpoint_exporter/catchpoint_exporter_test.go index 676c4df0b316..a154043b2ad9 100644 --- a/static/integrations/catchpoint_exporter/catchpoint_exporter_test.go +++ b/static/integrations/catchpoint_exporter/catchpoint_exporter_test.go @@ -11,46 +11,33 @@ import ( func TestConfig_UnmarshalYaml(t *testing.T) { strConfig := ` - port = "3030" - verbose = true - webhookpath = "/nondefault-webhook-path" - ` +port: "3030" +verbose_logging: true +webhook_path: "/nondefault-webhook-path"` var c Config require.NoError(t, yaml.UnmarshalStrict([]byte(strConfig), &c)) require.Equal(t, Config{ - Verbose: true, - Port: "3030", - WebhookPath: "/nondefault-webhook-path", + VerboseLogging: true, + Port: "3030", + WebhookPath: "/nondefault-webhook-path", }, c) } func TestConfig_NewIntegration(t *testing.T) { t.Run("integration with valid config", func(t *testing.T) { c := &Config{ - Verbose: true, - Port: "3030", - WebhookPath: "/nondefault-webhook-path", + VerboseLogging: true, + Port: "3030", + WebhookPath: "/nondefault-webhook-path", } i, err := c.NewIntegration(log.NewJSONLogger(os.Stdout)) require.NoError(t, err) require.NotNil(t, i) }) - - t.Run("integration with invalid config", func(t *testing.T) { - c := &Config{ - Verbose: "incorrect_value", - Port: "3030", - WebhookPath: "/nondefault-webhook-path", - } - - i, err := c.NewIntegration(log.NewJSONLogger(os.Stdout)) - require.Nil(t, i) - require.ErrorContains(t, err, "") - }) } func TestConfig_AgentKey(t *testing.T) { @@ -60,5 +47,5 @@ func TestConfig_AgentKey(t *testing.T) { ik := "agent-key" id, err := c.InstanceKey(ik) require.NoError(t, err) - require.Equal(t, "localhost:3030", id) + require.Equal(t, "3030", id) }