Skip to content

Commit 41d2071

Browse files
committed
expose prometheus HELP information
1 parent 4f87308 commit 41d2071

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

docs/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Following is the supported API format for prometheus encode:
1717
counter: monotonically increasing counter whose value can only increase
1818
histogram: counts samples in configurable buckets
1919
agg_histogram: counts samples in configurable buckets, pre-aggregated via an Aggregate stage
20+
help: the metric help text
2021
filters: a list of criteria to filter entries by
2122
key: the key to match and filter by
2223
value: the value to match and filter by
@@ -457,6 +458,7 @@ Following is the supported API format for writing metrics to an OpenTelemetry co
457458
counter: monotonically increasing counter whose value can only increase
458459
histogram: counts samples in configurable buckets
459460
agg_histogram: counts samples in configurable buckets, pre-aggregated via an Aggregate stage
461+
help: the metric help text
460462
filters: a list of criteria to filter entries by
461463
key: the key to match and filter by
462464
value: the value to match and filter by

pkg/api/encode_prom.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type PromConnectionInfo struct {
4949
type MetricsItem struct {
5050
Name string `yaml:"name" json:"name" doc:"the metric name"`
5151
Type MetricEncodeOperationEnum `yaml:"type" json:"type" doc:"(enum) one of the following:"`
52+
Help string `yaml:"help,omitempty" json:"help,omitempty" doc:"the metric help text"`
5253
Filters []MetricsFilter `yaml:"filters" json:"filters" doc:"a list of criteria to filter entries by"`
5354
ValueKey string `yaml:"valueKey" json:"valueKey" doc:"entry key from which to resolve metric value"`
5455
Labels []string `yaml:"labels" json:"labels" doc:"labels to be associated with the metric"`

pkg/pipeline/encode/encode_prom.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,25 @@ func (e *Prometheus) Cleanup(cleanupFunc interface{}) {
116116
}
117117

118118
func (e *Prometheus) addCounter(fullMetricName string, mInfo *metrics.Preprocessed) prometheus.Collector {
119-
counter := prometheus.NewCounterVec(prometheus.CounterOpts{Name: fullMetricName, Help: ""}, mInfo.TargetLabels())
119+
counter := prometheus.NewCounterVec(prometheus.CounterOpts{Name: fullMetricName, Help: mInfo.Help}, mInfo.TargetLabels())
120120
e.metricCommon.AddCounter(fullMetricName, counter, mInfo)
121121
return counter
122122
}
123123

124124
func (e *Prometheus) addGauge(fullMetricName string, mInfo *metrics.Preprocessed) prometheus.Collector {
125-
gauge := prometheus.NewGaugeVec(prometheus.GaugeOpts{Name: fullMetricName, Help: ""}, mInfo.TargetLabels())
125+
gauge := prometheus.NewGaugeVec(prometheus.GaugeOpts{Name: fullMetricName, Help: mInfo.Help}, mInfo.TargetLabels())
126126
e.metricCommon.AddGauge(fullMetricName, gauge, mInfo)
127127
return gauge
128128
}
129129

130130
func (e *Prometheus) addHistogram(fullMetricName string, mInfo *metrics.Preprocessed) prometheus.Collector {
131-
histogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{Name: fullMetricName, Help: ""}, mInfo.TargetLabels())
131+
histogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{Name: fullMetricName, Help: mInfo.Help}, mInfo.TargetLabels())
132132
e.metricCommon.AddHist(fullMetricName, histogram, mInfo)
133133
return histogram
134134
}
135135

136136
func (e *Prometheus) addAgghistogram(fullMetricName string, mInfo *metrics.Preprocessed) prometheus.Collector {
137-
agghistogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{Name: fullMetricName, Help: ""}, mInfo.TargetLabels())
137+
agghistogram := prometheus.NewHistogramVec(prometheus.HistogramOpts{Name: fullMetricName, Help: mInfo.Help}, mInfo.TargetLabels())
138138
e.metricCommon.AddAggHist(fullMetricName, agghistogram, mInfo)
139139
return agghistogram
140140
}

0 commit comments

Comments
 (0)