Skip to content

Commit

Permalink
feat: coredns_forge_info{version} metric
Browse files Browse the repository at this point in the history
this adds metric with current p2p-forge build version,
useful for tracking when which box got updated to what
  • Loading branch information
lidel committed Dec 12, 2024
1 parent 160a968 commit b6c4905
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

0 comments on commit b6c4905

Please sign in to comment.