Link Search Menu Expand Document

Metrics exporter

I think this is a good example of “small effort, big impact”

Background

  • We were running a service in K8s that we didn’t own
    • (all changes would have needed open-source contributions)
  • We wanted a couple of custom metrics that were not supported by this application yet
    • We wanted a quick way to add these, and if possible have a programmatic environment to add such things (sentiment one tends to get when working exclusively at the manifest level with blackbox docker images)

Solution

  • I just made an exporter microservice using Go
    • The Prometheus APIs make it really easy to expose such metrics for scraping into datadog, grafana, etc
    • i.e. as long as you can figure out the metric values, publishing them is very easy
  • To calculate the values for the additional things I wanted to monitor, I just had to hit this application’s APIs
    • Luckily they had a public OpenAPI schema, so I was able to use openapi-generator to generate typed Go code for their APIs
      • e.g. myTypedStuff, err := myClient.potatoAPI.ListImportantPotatoes(ctx).Execute()
      • not resp, err := http.Get("http://potato-api.potato-namespace.cluster.local/api/v0/important-potatoes")
flowchart LR; subgraph "k8s cluster"; datadog-agent -- scrapes --> me["metrics-exporter:8080/metrics"]; me -- talks to --> potato-api; end; datadog-agent -- publishes to --> datadog; style me fill:#10ed00,stroke:#333,stroke-width:2px;

Impact

  • We were able to monitor the additional pieces we wanted
    • These were actually mission critical signals that prod was working
    • Our alerts around these metrics actually caught a few issues in lower environments
  • We also had a programmatic environment flexible enough for any other metrics we wanted to add moving forward

Click where you wanna go
mindmap root((Sean's site)) :::link:/#here-is-my-site Awesome lists 😎 :::link:/awesome-lists/ Awesome tools :::link:/awesome-lists/tools.html Useless websites :::link:/awesome-lists/useless.html Dev stories :::link:/dev-stories/ Metrics exporter :::link:/dev-stories/metrics-exporter.html Pulumi contribution :::link:/dev-stories/pulumi-contribution.html Projects :::link:/projects/ Flake utils :::link:/projects/flake-utils.html Gcloud fzf :::link:/projects/gcloud-fzf.html Job controller :::link:/projects/job-controller.html K3d :::link:/projects/k3d.html This site :::link:/projects/this-site.html Yaml resume :::link:/projects/yaml-resume.html Resume :::link:/resume.html

gimme that fun lil site map