Skip to content

Commit

Permalink
added docs + altered catchpoint static/internal
Browse files Browse the repository at this point in the history
  • Loading branch information
BominRahmani committed Jun 7, 2024
1 parent be2c91e commit 2386650
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -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="<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" >}}

<!-- START GENERATED COMPATIBLE COMPONENTS -->

## 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 >}}

<!-- END GENERATED COMPATIBLE COMPONENTS -->
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
18 changes: 9 additions & 9 deletions internal/component/prometheus/exporter/catchpoint/catchpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ 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
err := river.Unmarshal([]byte(riverConfig), &args)
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)
}

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
Expand All @@ -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)
}
29 changes: 13 additions & 16 deletions static/integrations/catchpoint_exporter/catchpoint_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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(),
Expand Down
33 changes: 10 additions & 23 deletions static/integrations/catchpoint_exporter/catchpoint_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}

0 comments on commit 2386650

Please sign in to comment.