Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(probe): add target labels #77

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,14 @@ var _ = Describe("Check EMQX Exporter Probe", Label("probes"), func() {
WithTransform(func(m *dto.MetricFamily) dto.MetricType {
return m.GetType()
}, Equal(dto.MetricType_GAUGE)),
WithTransform(func(m *dto.MetricFamily) int {
return int(*m.Metric[0].Gauge.Value)
}, Equal(1)),
WithTransform(func(m *dto.MetricFamily) float64 {
return *m.GetMetric()[0].Gauge.Value
}, BeNumerically("==", 1)),
WithTransform(func(m *dto.MetricFamily) map[string]string {
return map[string]string{
m.GetMetric()[0].Label[0].GetName(): m.GetMetric()[0].Label[0].GetValue(),
}
}, HaveKeyWithValue("target", target)),
)),
))

Expand Down
6 changes: 6 additions & 0 deletions prober/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ func Handler(w http.ResponseWriter, r *http.Request, probes []config.Probe, logg
Subsystem: "mqtt",
Name: "probe_success",
Help: "Displays whether or not the probe was a success",
ConstLabels: prometheus.Labels{
"target": probe.Target,
},
})
probeDurationGauge := prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "emqx",
Subsystem: "mqtt",
Name: "probe_duration_seconds",
Help: "Returns how long the probe took to complete in seconds",
ConstLabels: prometheus.Labels{
"target": probe.Target,
},
})

registry := prometheus.NewRegistry()
Expand Down
Loading