Skip to content

Commit

Permalink
feat: add slo-detail-links, #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Körtgen committed Dec 20, 2024
1 parent 29906bb commit bede06a
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 20 deletions.
27 changes: 17 additions & 10 deletions charts/slo-reporting/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# slo-reporting

![Version: 0.3.14](https://img.shields.io/badge/Version-0.3.14-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: latest](https://img.shields.io/badge/AppVersion-latest-informational?style=flat-square)
![Version: 0.3.18](https://img.shields.io/badge/Version-0.3.18-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.3.18](https://img.shields.io/badge/AppVersion-0.3.18-informational?style=flat-square)

Excel compatible SLO reporting tool for Prometheus.
Excel compatible SLO reporting tool for Prometheus / Pyrra.

**Homepage:** <https://github.com/colenio/slo-reporting>

Expand Down Expand Up @@ -37,19 +37,19 @@ Kubernetes: `>= 1.26.3`
| config.metrics.cronjob.enabled | bool | `true` | Should the export-metrics job be enabled |
| config.metrics.cronjob.schedule | string | `"@daily"` | The cronjob schedule for running the export-metrics job (default: nightly at 2AM) |
| config.metrics.enabled | bool | `true` | Should SLO reports be generated from configured SLOs |
| config.metrics.objectives | list | `[{"goal":99.9,"name":"prometheus-uptime","query":"100 * avg(avg_over_time(up{job=~\"prometheus.*\"}[5m]))"},{"goal":99.9,"goal_query":"100 * pyrra_objective","name":"slo","query":"100 * pyrra_availability"}]` | List of SLOs to report on |
| config.metrics.objectives | list | `[{"goal":99.9,"name":"prometheus-uptime","query":"100 * avg(avg_over_time(up{job=~\"prometheus.*\"}[5m]))"},{"goal_query":"100 * pyrra_objective","name":"slo","query":"100 * pyrra_availability"}]` | List of SLOs to report on |
| config.metrics.objectives[0].goal | float | `99.9` | The goal of the SLO in percentage |
| config.metrics.objectives[0].query | string | `"100 * avg(avg_over_time(up{job=~\"prometheus.*\"}[5m]))"` | Prometheus query to evaluate |
| config.metrics.objectives[1] | object | `{"goal":99.9,"goal_query":"100 * pyrra_objective","name":"slo","query":"100 * pyrra_availability"}` | [Pyrra](https://github.com/pyrra-dev/pyrra) Example, `slo` is the metric-label |
| config.metrics.objectives[1] | object | `{"goal_query":"100 * pyrra_objective","name":"slo","query":"100 * pyrra_availability"}` | [Pyrra](https://github.com/pyrra-dev/pyrra) Example, `slo` is the metric-label |
| config.metrics.prometheus.url | string | `"http://prometheus-community-kube-prometheus.observability:9090"` | Prometheus URL to query |
| config.metrics.step | string | `"P1D"` | In what granularity (step-size) should SLOs be reported |
| config.metrics.window | string | `"P30D"` | Evaluation window for SLOs |
| config.status.enabled | bool | `true` | Should a status API be created which aggregates alerts from multiple sources? |
| config.status.interval | string | `"PT1M"` | Scrape interval of alert sources |
| config.status.monitors | object | `{"alertmanager":[{"active":true,"filters":["receiver=email","severity=critical","relevance=health-status"],"inhibited":false,"name":"alertmanager-project1","silenced":false,"unprocessed":false,"url":"http://alertmanager-operated.observability:9093/api/v2/alerts"}],"azure":[{"name":"azure-project-1","subscription_id":"XXXXXX-XXXX-XXXXXX-XXXX-XXXXXX"}],"prometheus":[{"name":"prometheus-project-1","query":"ALERTS{alertstate=\"firing\", severity=\"critical\", relevance=\"health-status\"}","url":"http://prometheus-operated.observability:9090"}]}` | List of alert monitors to aggregate |
| config.status.monitors.alertmanager | list | `[{"active":true,"filters":["receiver=email","severity=critical","relevance=health-status"],"inhibited":false,"name":"alertmanager-project1","silenced":false,"unprocessed":false,"url":"http://alertmanager-operated.observability:9093/api/v2/alerts"}]` | List of a Alertmanager Monitors |
| config.status.monitors.alertmanager[0] | object | `{"active":true,"filters":["receiver=email","severity=critical","relevance=health-status"],"inhibited":false,"name":"alertmanager-project1","silenced":false,"unprocessed":false,"url":"http://alertmanager-operated.observability:9093/api/v2/alerts"}` | An example of an Alertmanager monitor |
| config.status.monitors.alertmanager[0].filters | list | `["receiver=email","severity=critical","relevance=health-status"]` | List of filters to apply, cf. [AlertManager OpenAPI](https://github.com/prometheus/alertmanager/blob/main/api/v2/openapi.yaml) |
| config.status.monitors | object | `{"alertmanager":[{"active":true,"filters":["severity=critical","relevance=health-status"],"inhibited":false,"name":"alertmanager-project1","receiver":".*","silenced":false,"unprocessed":false,"url":"http://alertmanager-operated.observability:9093/api/v2/alerts"}],"azure":[{"name":"azure-project-1","subscription_id":"XXXXXX-XXXX-XXXXXX-XXXX-XXXXXX"}],"prometheus":[{"name":"prometheus-project-1","query":"ALERTS{alertstate=\"firing\", severity=\"critical\", relevance=\"health-status\"}","url":"http://prometheus-operated.observability:9090"}]}` | List of alert monitors to aggregate |
| config.status.monitors.alertmanager | list | `[{"active":true,"filters":["severity=critical","relevance=health-status"],"inhibited":false,"name":"alertmanager-project1","receiver":".*","silenced":false,"unprocessed":false,"url":"http://alertmanager-operated.observability:9093/api/v2/alerts"}]` | List of a Alertmanager Monitors |
| config.status.monitors.alertmanager[0] | object | `{"active":true,"filters":["severity=critical","relevance=health-status"],"inhibited":false,"name":"alertmanager-project1","receiver":".*","silenced":false,"unprocessed":false,"url":"http://alertmanager-operated.observability:9093/api/v2/alerts"}` | An example of an Alertmanager monitor |
| config.status.monitors.alertmanager[0].filters | list | `["severity=critical","relevance=health-status"]` | List of filters to apply, cf. [AlertManager OpenAPI](https://github.com/prometheus/alertmanager/blob/main/api/v2/openapi.yaml) |
| config.status.monitors.alertmanager[0].url | string | `"http://alertmanager-operated.observability:9093/api/v2/alerts"` | Alertmanager URL to query |
| config.status.monitors.azure | list | `[{"name":"azure-project-1","subscription_id":"XXXXXX-XXXX-XXXXXX-XXXX-XXXXXX"}]` | List of Azure Monitors |
| config.status.monitors.azure[0] | object | `{"name":"azure-project-1","subscription_id":"XXXXXX-XXXX-XXXXXX-XXXX-XXXXXX"}` | An example of an Azure monitor |
Expand All @@ -65,10 +65,17 @@ Kubernetes: `>= 1.26.3`
| config.ui.icons.favicon | string | `"/static/favico.png"` | |
| config.ui.slo.links[0].icon | string | `"https://raw.githubusercontent.com/pyrra-dev/pyrra/main/ui/public/favicon.ico"` | |
| config.ui.slo.links[0].name | string | `"Pyrra"` | |
| config.ui.slo.links[0].url | string | `"http://localhost:8080"` | |
| config.ui.slo.links[0].url | string | `"http://localhost:9099"` | |
| config.ui.slo.links[1].icon | string | `"https://raw.githubusercontent.com/prometheus/docs/main/static/favicon.ico"` | |
| config.ui.slo.links[1].name | string | `"Prometheus"` | |
| config.ui.slo.links[1].url | string | `"http://localhost:9090"` | |
| config.ui.slo.links[2].icon | string | `"https://raw.githubusercontent.com/grafana/grafana/main/public/img/fav32.png"` | |
| config.ui.slo.links[2].name | string | `"Grafana"` | |
| config.ui.slo.links[2].url | string | `"http://localhost:3000"` | |
| config.ui.slo.templates[0].name | string | `"Pyrra"` | |
| config.ui.slo.templates[0].template | string | `"http://localhost:9099/objectives?expr={{__name__='{name}'}}"` | |
| config.ui.slo.templates[1].name | string | `"Grafana"` | |
| config.ui.slo.templates[1].template | string | `"http://localhost:3000/d/pyrra-detail/pyrra-detail?var-slo={name}"` | |
| config.ui.status.links[0].icon | string | `"https://raw.githubusercontent.com/grafana/grafana/main/public/img/fav32.png"` | |
| config.ui.status.links[0].name | string | `"Grafana"` | |
| config.ui.status.links[0].url | string | `"http://localhost:3000"` | |
Expand Down Expand Up @@ -114,4 +121,4 @@ Kubernetes: `>= 1.26.3`
| serviceAccount.name | string | `""` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.13.1](https://github.com/norwoodj/helm-docs/releases/v1.13.1)
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)
13 changes: 11 additions & 2 deletions charts/slo-reporting/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,20 @@ config:
slo:
links:
- name: Pyrra
url: http://localhost:8080
url: http://localhost:9099
icon: "https://raw.githubusercontent.com/pyrra-dev/pyrra/main/ui/public/favicon.ico"
- name: Prometheus
url: http://localhost:9090
icon: "https://raw.githubusercontent.com/prometheus/docs/main/static/favicon.ico"
- name: Grafana
url: http://localhost:3000
icon: "https://raw.githubusercontent.com/grafana/grafana/main/public/img/fav32.png"
templates:
- name: Pyrra
template: "http://localhost:9099/objectives?expr={{__name__='{name}'}}"
- name: Grafana
template: "http://localhost:3000/d/pyrra-detail/pyrra-detail?var-slo={name}"

status:
links:
- name: Grafana
Expand Down Expand Up @@ -99,10 +108,10 @@ config:
url: http://alertmanager-operated.observability:9093/api/v2/alerts
# -- List of filters to apply, cf. [AlertManager OpenAPI](https://github.com/prometheus/alertmanager/blob/main/api/v2/openapi.yaml)
filters:
- "receiver=email"
- "severity=critical"
- "relevance=health-status"
active: True
receiver: ".*" # (email|slack|webhook)
silenced: False
inhibited: False
unprocessed: False
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ services:
- grafana-data:/var/lib/grafana/
environment:
GF_SECURITY_ADMIN_PASSWORD: admin

pyrra:
image: ghcr.io/pyrra-dev/pyrra:v0.8.1
ports: ["9099:9099"]
12 changes: 9 additions & 3 deletions src/config/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ ui:
slo:
links:
- name: Pyrra
url: http://localhost:8080
url: http://localhost:9099
icon: "https://raw.githubusercontent.com/pyrra-dev/pyrra/main/ui/public/favicon.ico"
- name: Prometheus
url: http://localhost:9090
icon: "https://raw.githubusercontent.com/prometheus/docs/main/static/favicon.ico"
templates:
- name: Pyrra
template: "http://localhost:9099/objectives?expr={{__name__='{name}'}}"
- name: Grafana
template: "http://localhost:3000/d/pyrra-detail/pyrra-detail?var-slo={name}"

status:
links:
- name: Grafana
Expand Down Expand Up @@ -59,8 +65,8 @@ status:
# https://github.com/prometheus/alertmanager/blob/main/api/v2/openapi.yaml
active: True
filters: []
# - "severity=critical"
# - "relevance=health-status"
# - "severity=critical"
# - "relevance=health-status"
inhibited: False
receiver: ".*" # (email|slack|webhook)
silenced: False
Expand Down
2 changes: 1 addition & 1 deletion src/pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
# https://docs.pytest.org/en/stable/how-to/logging.html?highlight=logging#live-logs
log_cli=true
#log_cli=true
#log_level=DEBUG
log_level=INFO
1 change: 0 additions & 1 deletion src/tests/slo/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from config.settings import settings


@pytest.mark.skip("TODO")
def test_slo_export(client: TestClient) -> None:
path = f"{settings.api_base}/slo/export"
response = client.get(f"{path}/csv")
Expand Down
13 changes: 10 additions & 3 deletions src/ui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

from pydantic import BaseModel, Field


class UILink(BaseModel):
name: str = Field(..., description="Name of the link")
url: str = Field(..., description="URL of the link")
icon: str = Field(..., description="Icon of the link (font-awesome class or image url)")


class IconConfig(BaseModel):
favicon: str = Field("/static/favico.png", description="Favicon URL")
brand: str = Field("/static/img/brand.png", description="Brand logo URL")
Expand All @@ -17,9 +15,18 @@ class IconConfig(BaseModel):
class ViewConfig(BaseModel):
links: List[UILink] = Field(default_factory=list, description="List of links")

class LinkTemplate(BaseModel):
name: str = Field(..., description="Name of the template")
template: str = Field(..., description="Template name")

def link_for(self, context: dict) -> str:
return self.template.format(**context)

class SloViewConfig(ViewConfig):
templates: List[LinkTemplate] = Field(default_factory=list, description="List of templates")

class UIConfig(BaseModel):
icons: IconConfig = Field(default_factory=IconConfig, description="Icon configuration for the UI")
about: ViewConfig = Field(default_factory=ViewConfig, description="View configuration for the about page")
slo: ViewConfig = Field(default_factory=ViewConfig, description="Extra View configuration for the SLO page")
slo: SloViewConfig = Field(default_factory=SloViewConfig, description="Extra View configuration for the SLO page")
status: ViewConfig = Field(default_factory=ViewConfig, description="Extra View configuration for the Status page")
3 changes: 3 additions & 0 deletions src/ui/templates/slo.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ <h5 class="card-title">{{ name }}</h5>
</div>
<div class="card-body">
<p class="card-text fs-1">{{ slo.value | round(2) }} %</p>
{% for tpl in config.templates %}
<a href="{{ tpl.link_for({'name':name}) }}" target="_blank" class="btn btn-small btn-{{ slo.style }}">{{ tpl.name }}</a>
{% endfor %}
</div>
<div class="card-footer">
<p class="card-text">Goal: {{ slo.goal }} %</p>
Expand Down

0 comments on commit bede06a

Please sign in to comment.