-
Notifications
You must be signed in to change notification settings - Fork 485
/
integration.go
50 lines (42 loc) · 1.75 KB
/
integration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package integrations
import (
"context"
"net/http"
"github.com/go-kit/log"
"github.com/grafana/agent/pkg/integrations/config"
)
// Config provides the configuration and constructor for an integration.
type Config interface {
// Name returns the name of the integration and the key that will be used to
// pull the configuration from the Agent config YAML.
Name() string
// InstanceKey should return the key the reprsents the config, which will be
// used to populate the value of the `instance` label for metrics.
//
// InstanceKey is given an agentKey that represents the agent process. This
// may be used if the integration being configured applies to an entire
// machine.
//
// This method may not be invoked if the instance key for a Config is
// overridden.
InstanceKey(agentKey string) (string, error)
// NewIntegration returns an integration for the given with the given logger.
NewIntegration(l log.Logger) (Integration, error)
}
// An Integration is a process that integrates with some external system and
// pulls telemetry data.
type Integration interface {
// MetricsHandler returns an http.Handler that will return metrics.
MetricsHandler() (http.Handler, error)
// ScrapeConfigs returns a set of scrape configs that determine where metrics
// can be scraped.
ScrapeConfigs() []config.ScrapeConfig
// Run should start the integration and do any required tasks, if necessary.
// For example, an Integration that requires a persistent connection to a
// database would establish that connection here. If the integration doesn't
// need to do anything, it should wait for the ctx to be canceled.
//
// An error will be returned if the integration failed. Integrations should
// not return the ctx error.
Run(ctx context.Context) error
}