Skip to content

Commit

Permalink
feat(probe): add target labels
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Nov 8, 2023
1 parent 4fa41c4 commit 54dc5ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 54dc5ef

Please sign in to comment.