Documentation
¶
Index ¶
- Variables
- func CheckConfig() error
- func Init(pushData func(wr *prompbmarshal.WriteRequest))
- func Stop()
- func WriteAPIV1Targets(w io.Writer, state string)
- func WriteHumanReadableTargetsStatus(w io.Writer, showOriginalLabels bool)
- type Config
- type FileSDConfig
- type GlobalConfig
- type ScrapeConfig
- type ScrapeWork
- type StaticConfig
Constants ¶
This section is empty.
Variables ¶
var ( // PendingScrapeConfigs - zero value means, that // all scrapeConfigs are inited and ready for work. PendingScrapeConfigs int32 )
Functions ¶
func CheckConfig ¶ added in v1.35.6
func CheckConfig() error
CheckConfig checks -promscrape.config for errors and unsupported options.
func Init ¶
func Init(pushData func(wr *prompbmarshal.WriteRequest))
Init initializes Prometheus scraper with config from the `-promscrape.config`.
Scraped data is passed to pushData.
func WriteAPIV1Targets ¶ added in v1.45.0
WriteAPIV1Targets writes /api/v1/targets to w according to https://prometheus.io/docs/prometheus/latest/querying/api/#targets
func WriteHumanReadableTargetsStatus ¶
WriteHumanReadableTargetsStatus writes human-readable status for all the scrape targets to w.
Types ¶
type Config ¶
type Config struct {
Global GlobalConfig `yaml:"global"`
ScrapeConfigs []ScrapeConfig `yaml:"scrape_configs"`
// contains filtered or unexported fields
}
Config represents essential parts from Prometheus config defined at https://prometheus.io/docs/prometheus/latest/configuration/configuration/
type FileSDConfig ¶
type FileSDConfig struct {
Files []string `yaml:"files"`
}
FileSDConfig represents file-based service discovery config.
See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#file_sd_config
type GlobalConfig ¶
type GlobalConfig struct {
ScrapeInterval time.Duration `yaml:"scrape_interval,omitempty"`
ScrapeTimeout time.Duration `yaml:"scrape_timeout,omitempty"`
ExternalLabels map[string]string `yaml:"external_labels,omitempty"`
}
GlobalConfig represents essential parts for `global` section of Prometheus config.
See https://prometheus.io/docs/prometheus/latest/configuration/configuration/
type ScrapeConfig ¶
type ScrapeConfig struct {
JobName string `yaml:"job_name"`
ScrapeInterval time.Duration `yaml:"scrape_interval,omitempty"`
ScrapeTimeout time.Duration `yaml:"scrape_timeout,omitempty"`
MetricsPath string `yaml:"metrics_path,omitempty"`
HonorLabels bool `yaml:"honor_labels,omitempty"`
HonorTimestamps bool `yaml:"honor_timestamps,omitempty"`
Scheme string `yaml:"scheme,omitempty"`
Params map[string][]string `yaml:"params,omitempty"`
BasicAuth *promauth.BasicAuthConfig `yaml:"basic_auth,omitempty"`
BearerToken string `yaml:"bearer_token,omitempty"`
BearerTokenFile string `yaml:"bearer_token_file,omitempty"`
TLSConfig *promauth.TLSConfig `yaml:"tls_config,omitempty"`
StaticConfigs []StaticConfig `yaml:"static_configs,omitempty"`
FileSDConfigs []FileSDConfig `yaml:"file_sd_configs,omitempty"`
KubernetesSDConfigs []kubernetes.SDConfig `yaml:"kubernetes_sd_configs,omitempty"`
OpenStackSDConfigs []openstack.SDConfig `yaml:"openstack_sd_configs,omitempty"`
ConsulSDConfigs []consul.SDConfig `yaml:"consul_sd_configs,omitempty"`
DockerSwarmConfigs []dockerswarm.SDConfig `yaml:"dockerswarm_sd_configs,omitempty"`
DNSSDConfigs []dns.SDConfig `yaml:"dns_sd_configs,omitempty"`
EC2SDConfigs []ec2.SDConfig `yaml:"ec2_sd_configs,omitempty"`
GCESDConfigs []gce.SDConfig `yaml:"gce_sd_configs,omitempty"`
RelabelConfigs []promrelabel.RelabelConfig `yaml:"relabel_configs,omitempty"`
MetricRelabelConfigs []promrelabel.RelabelConfig `yaml:"metric_relabel_configs,omitempty"`
SampleLimit int `yaml:"sample_limit,omitempty"`
// These options are supported only by lib/promscrape.
DisableCompression bool `yaml:"disable_compression,omitempty"`
DisableKeepAlive bool `yaml:"disable_keepalive,omitempty"`
StreamParse bool `yaml:"stream_parse,omitempty"`
// contains filtered or unexported fields
}
ScrapeConfig represents essential parts for `scrape_config` section of Prometheus config.
See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
type ScrapeWork ¶
type ScrapeWork struct {
// Unique ID for the ScrapeWork.
ID uint64
// Full URL (including query args) for the scrape.
ScrapeURL string
// Interval for scraping the ScrapeURL.
ScrapeInterval time.Duration
// Timeout for scraping the ScrapeURL.
ScrapeTimeout time.Duration
// How to deal with conflicting labels.
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
HonorLabels bool
// How to deal with scraped timestamps.
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config
HonorTimestamps bool
// OriginalLabels contains original labels before relabeling.
//
// These labels are needed for relabeling troubleshooting at /targets page.
OriginalLabels []prompbmarshal.Label
// Labels to add to the scraped metrics.
//
// The list contains at least the following labels according to https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
//
// * job
// * __address__
// * __scheme__
// * __metrics_path__
// * __param_<name>
// * __meta_*
// * user-defined labels set via `relabel_configs` section in `scrape_config`
//
// See also https://prometheus.io/docs/concepts/jobs_instances/
Labels []prompbmarshal.Label
// Auth config
AuthConfig *promauth.Config
// Optional `metric_relabel_configs`.
MetricRelabelConfigs []promrelabel.ParsedRelabelConfig
// The maximum number of metrics to scrape after relabeling.
SampleLimit int
// Whether to disable response compression when querying ScrapeURL.
DisableCompression bool
// Whether to disable HTTP keep-alive when querying ScrapeURL.
DisableKeepAlive bool
// Whether to parse target responses in a streaming manner.
StreamParse bool
// contains filtered or unexported fields
}
ScrapeWork represents a unit of work for scraping Prometheus metrics.
func (*ScrapeWork) Job ¶ added in v1.34.8
func (sw *ScrapeWork) Job() string
Job returns job for the ScrapeWork
func (*ScrapeWork) LabelsString ¶ added in v1.34.9
func (sw *ScrapeWork) LabelsString() string
LabelsString returns labels in Prometheus format for the given sw.
type StaticConfig ¶
type StaticConfig struct {
Targets []string `yaml:"targets"`
Labels map[string]string `yaml:"labels,omitempty"`
}
StaticConfig represents essential parts for `static_config` section of Prometheus config.
See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#static_config