Skip to content

Commit 7a6b1d3

Browse files
committed
feat: Added hostname & model labels to info metric
1 parent fafbd96 commit 7a6b1d3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: pkg/probe/system_status.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func probeSystemStatus(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Met
2626
mVersion = prometheus.NewDesc(
2727
"fortigate_version_info",
2828
"System version and build information",
29-
[]string{"serial", "version", "build"}, nil,
29+
[]string{"hostname", "model", "serial", "version", "build"}, nil,
3030
)
3131
)
3232

@@ -35,6 +35,10 @@ func probeSystemStatus(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Met
3535
Serial string
3636
Version string
3737
Build int64
38+
Results struct {
39+
Model string
40+
Hostname string
41+
}
3842
}
3943
var st systemStatus
4044

@@ -44,7 +48,7 @@ func probeSystemStatus(c http.FortiHTTP, meta *TargetMetadata) ([]prometheus.Met
4448
}
4549

4650
m := []prometheus.Metric{
47-
prometheus.MustNewConstMetric(mVersion, prometheus.GaugeValue, 1.0, st.Serial, st.Version, fmt.Sprintf("%d", st.Build)),
51+
prometheus.MustNewConstMetric(mVersion, prometheus.GaugeValue, 1.0, st.Results.Hostname, st.Results.Model, st.Serial, st.Version, fmt.Sprintf("%d", st.Build)),
4852
}
4953
return m, true
5054
}

Diff for: pkg/probe/testdata/status.jsonnet

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
{
33
"http_method":"GET",
44
"results":{
5+
"model_name":"FortiGate",
6+
"model_number":"800D",
7+
"model":"FG800D",
8+
"hostname":"Firewall1",
9+
"log_disk_status":"not_available"
510
},
611
"vdom":"root",
712
"path":"system",

0 commit comments

Comments
 (0)