Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

feat: add custom labels to sloth_slo_info metric - #4

Merged
cxdy merged 1 commit into
linode-obs:mainfrom
cxdy:feat/custom-info-labels
Oct 30, 2024
Merged

cxdy merged 1 commit into
linode-obs:mainfrom
cxdy:feat/custom-info-labels

Conversation

@cxdy

@cxdy cxdy commented Oct 29, 2024

Copy link
Copy Markdown
Member

Adds the ability to define info_labels to be appended to the sloth_slo_info{} metric

For example, we can generate this template:

version: "prometheus/v1"
service: "nagios"
labels:
  component: "nagios"
  environment: "production"
# this file is used to generate prometheus rules with sloth - https://github.com/slok/sloth
# to use it, run:
# sloth generate -i sloth/nagios.yml -o infra/nagios_slo.yml
# uses default window of 30 days
# window defined during generation https://sloth.dev/usage/slo-period-windows/#custom-slo-period-catalog
slos:
  - name: "nagios-availability"
    objective: 90 # low due to 5 min window and scrape_interval of 30s
    description: "Nagios Availability via prometheus-nagios-exporter scrapes"
    info_labels:
      infoLabelOne: true
      infoLabelTwo: "hello world"
    sli:
      events: # https://stackoverflow.com/a/71846686
        error_query: sum(count_over_time(up{job="nagios_exporter",environment="production"}[{{.window}}]) - sum_over_time(nagios_up{environment="production", job="nagios_exporter" ,component="nagios"}[{{.window}}]))
        total_query: sum(count_over_time(up{job="nagios_exporter",environment="production"}[{{.window}}]))
    .....

Into this:

---
# Code generated by Sloth (dev): https://github.com/slok/sloth.
# DO NOT EDIT.

groups:
- name: sloth-slo-sli-recordings-nagios-nagios-availability
  rules:
  ....
  - record: sloth_slo_info
    expr: vector(1)
    labels:
      component: nagios
      environment: production
      infoLabelOne: true
      sloth_id: nagios-nagios-availability
      sloth_mode: cli-gen-prom
      sloth_objective: "90"
      sloth_service: nagios
      sloth_slo: nagios-availability
      sloth_spec: prometheus/v1
      sloth_version: dev
      infoLabelTwo: "hello world"
  ....

Redacted a bunch of output for readability but you get the gist.

@cxdy
cxdy requested review from dennisme and wbollock October 29, 2024 02:41
Comment thread pkg/kubernetes/api/sloth/v1/types.go Outdated
@dennisme
dennisme requested review from dennisme-akamai and removed request for dennisme-akamai October 30, 2024 21:08
Comment thread CHANGELOG.md Outdated
Comment thread CHANGELOG.md Outdated
@dennisme

Copy link
Copy Markdown

looks good!

@cxdy
cxdy merged commit aa94b31 into linode-obs:main Oct 30, 2024
@cxdy
cxdy deleted the feat/custom-info-labels branch October 30, 2024 21:38
This was referenced Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants