Skip to content

feat: add custom labels to sloth_slo_info metric #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

cxdy
Copy link
Member

@cxdy cxdy commented Oct 29, 2024

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
@cxdy cxdy force-pushed the feat/custom-info-labels branch 3 times, most recently from 7dddf19 to 57bf1c7 Compare October 29, 2024 18:40
@dennisme dennisme requested review from dennisme-akamai and removed request for dennisme-akamai October 30, 2024 21:08
@dennisme
Copy link

looks good!

@cxdy cxdy force-pushed the feat/custom-info-labels branch from 1617f8a to 7aeee63 Compare October 30, 2024 21:29
@cxdy cxdy merged commit aa94b31 into linode-obs:main Oct 30, 2024
12 checks passed
@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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants