Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MetricQuery ¶ added in v0.8.4
type MetricQuery struct {
Label string
// Query is a format string. %s is replaced with the rate window (e.g. "5m", "4h").
// Queries without %s are used as-is.
Query string
// PrometheusMetric is the raw Prometheus metric name used in the query.
PrometheusMetric string
// GroupByConnector indicates the query is aggregated with `sum by (connector) (...)`
// and results should be broken out per connector using the `connector` series label.
GroupByConnector bool
// Overridden is true when PrometheusMetric came from a user-configured
// metric-name override rather than the default series name. An overridden
// query that still returns no data is actionable (the override was set
// precisely to fix an empty result), so it is logged louder than a routine
// empty default.
Overridden bool
}
MetricQuery defines a single Prometheus metric to collect.
func BrokerQueryDefinitions ¶ added in v0.8.4
func BrokerQueryDefinitions(overrides map[string]string) []MetricQuery
BrokerQueryDefinitions returns the standard Kafka broker Prometheus queries. overrides maps a logical label (e.g. "BytesInPerSec") to the base series name this cluster's exporter actually exposes; an entry with an empty value is ignored. The overridden name is substituted into kcp's existing query wrapping and set as PrometheusMetric, so applyLabelFilter injection keeps working. Pass nil for the defaults.
func ConnectQueryDefinitions ¶ added in v0.8.4
func ConnectQueryDefinitions(overrides map[string]string) []MetricQuery
ConnectQueryDefinitions returns the Kafka Connect worker Prometheus queries. overrides maps a logical Connect label (e.g. "task-count") to the base series name this cluster's exporter actually exposes; an entry with an empty value is ignored. The overridden name is substituted into kcp's existing wrapping and set as PrometheusMetric, so applyLabelFilter injection keeps working, and per-connector metrics keep their sum by (connector) grouping. Pass nil for the defaults.
type PrometheusService ¶
type PrometheusService struct {
// contains filtered or unexported fields
}
PrometheusService collects Kafka metrics from a Prometheus server
func NewPrometheusService ¶
func NewPrometheusService(promClient *client.PrometheusClient, queries []MetricQuery, labels map[string]string) *PrometheusService
NewPrometheusService creates a new Prometheus metrics service. Labels is an optional map of Prometheus label selectors to scope queries to a specific target (e.g. {"job": "confluent/connect-jmx-exporter"}). Pass nil for no filtering.
func (*PrometheusService) CollectMetrics ¶
func (s *PrometheusService) CollectMetrics(ctx context.Context, queryRange time.Duration) (*types.ProcessedClusterMetrics, error)
CollectMetrics queries Prometheus for all Kafka metrics over the specified range