sloy is a tool to collect and export SLO (Service Level Objectives) metrics, inspired by Google's slo-generator. The main use case of sloy is to collect data and determine the first initial SLO.
Backends:
- Elasticsearch
- Google Cloud Logging
Exporters:
- Google Sheets
- Slack
Make sure you have rye installed for Python package management.
git clone https://github.com/oyindonesia/sloy.git
cd sloy
# Install dependencies
rye sync
To run the app in development mode:
rye run dev
Global configuration is used for storing backends and exporters shared configuration. Sample config:
---
backends:
elasticsearch:
url: ${ELASTICSEARCH_URL}
basic_auth:
username: ${ELASTICSEARCH_USERNAME}
password: ${ELASTICSEARCH_PASSWORD}
cloudlogging:
credentials: ${GCP_CREDENTIALS}
project_id: ${GCP_PROJECT_ID}
exporters:
slack:
token: ${SLACK_TOKEN}
channel: ${SLACK_CHANNEL}
gsheets:
credentials: ${GCP_CREDENTIALS}
sheet_id: ${SHEET_ID}
worksheet_name: Sheet1
For each backend, the required fields are:
elasticsearch
: Elasticsearch backend configurationurl
: Elasticsearch URLbasic_auth
: Basic authentication configurationusername
: Elasticsearch usernamepassword
: Elasticsearch password
cloudlogging
: Google Cloud Logging backend configurationcredentials
: Google Cloud credentialsproject_id
: Google Cloud project ID
For each exporter, the required fields are:
slack
: Slack exporter configurationtoken
: Slack tokenchannel
: Slack channel
gsheets
: Google Sheets exporter configurationcredentials
: Google Cloud credentialssheet_id
: Google Sheets IDworksheet_name
: Google Sheets worksheet name
SLO configuration is used for defining SLOs. Sample config:
name: Database Latency SLO
description: >
Latency for Postgres Database, 99th percentile of latencies should be less than 10ms
backend: elasticsearch
exporters:
- gsheets:
sheet_id: THIS_IS_A_GOOGLE_SHEET_ID
worksheet_name: database_latency
time_window: 7d
method: percentile
service_level_indicator:
percentiles: [95.0, 99.0, 99.9]
es_index: traces-apm*,apm-*,logs-apm*,apm-*,metrics-apm*,apm-*
value_key: transaction.duration.us
query: >
{
"query": {
"bool": {
"must": [],
"filter": [
{
"exists": {
"field": "transaction.duration.us"
}
},
{
"match_phrase": {
"labels.db_system": "postgresql"
}
}
],
"should": [],
"must_not": []
}
}
}
The required fields are:
name
: SLO namebackend
: Backend to usemethod
: Method to calculate SLO, the available methods are:percentile
: Calculate SLO based on percentileerror_rate
: Calculate SLO based on bad / all events
service_level_indicator
: Service level indicator configuration, this depends on the backend and the method usedtime_window
: Time window to calculate SLO
The optional fields are:
description
: SLO descriptionexporters
: Exporters to use
elasticsearch
For method percentile
, the required fields are:
percentiles
: Percentiles to calculatees_index
: Elasticsearch index patternvalue_key
: Key to calculate percentilequery
: Elasticsearch query
For method error_rate
, the required fields are:
es_index
: Elasticsearch index patternquery_bad
: Elasticsearch queryquery_good
: Elasticsearch query
cloudlogging
For method percentile
, the required fields are:
percentiles
: Percentiles to calculatevalue_key
: Key to calculate percentilequery
: Cloud Logging query
For method error_rate
, the required fields are:
filter_bad
: Cloud Logging filterfilter_good
: Cloud Logging filter
gsheets
The required fields for the global config are:
credentials
: Google Cloud credentialssheet_id
: Google Sheets IDworksheet_name
: Google Sheets worksheet name
You can also use the optional fields for SLO configuration. If there isn't any config specified in the SLO configuration, the exporter will use the global configuration. The optional fields for SLO configuration are:
sheet_id
: Google Sheets IDworksheet_name
: Google Sheets worksheet name
slack
The required fields for the global config are:
token
: Slack tokenchannel
: Slack channel
You can also use the optional fields for SLO configuration. If there isn't any config specified in the SLO configuration, the exporter will use the global configuration. The optional fields for SLO configuration are:
channel
: Slack channel
To calculate SLO, start the app and hit it with the following command:
curl -X POST --data-binary @slo_config.yaml <URL>/compute
or
curl -X POST --header "Content-Type: application/json" -d '{slo_config_json}' <URL>/compute