diff --git a/docs/METRICS.md b/docs/METRICS.md index 9787ca0..f6ec86e 100644 --- a/docs/METRICS.md +++ b/docs/METRICS.md @@ -6,6 +6,8 @@ It includes default [Prometheus Glient metrics](https://prometheus.io/docs/guide ### Forge metrics +- `coredns_forge_info{version}` - info about p2p-forge instance, useful for tracking when version update occured on each box + #### `ipparser` plugin (DNS A/AAAA) - `coredns_forge_ipparser_responses_total{type}` - dynamic DNS `A`/`AAAA` responses generated by `ipparser` plugin for `ip.peerid.domain` and `peerid.domain`, including `NODATA-*` ones. diff --git a/main.go b/main.go index 1e8e7cb..fa9bc3b 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( // Load CoreDNS + p2p-forge plugins _ "github.com/ipshipyard/p2p-forge/plugins" + "github.com/prometheus/client_golang/prometheus" "github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/coremain" @@ -39,9 +40,22 @@ func init() { func main() { fmt.Printf("%s %s\n", name, version) // always print version + registerVersionMetric() err := godotenv.Load() if err == nil { fmt.Println(".env found and loaded") } coremain.Run() } + +func registerVersionMetric() { + m := prometheus.NewGauge(prometheus.GaugeOpts{ + Namespace: "coredns", + Subsystem: "forge", + Name: "info", + Help: "Information about p2p-forge instance.", + ConstLabels: prometheus.Labels{"version": version}, + }) + prometheus.MustRegister(m) + m.Set(1) +}