Skip to content

sketch-hq/sentry-prometheus-exporter

 
 

Repository files navigation

Welcome to Sentry Prometheus Exporter 👋

License: GNU General Public License v2.0 Dockehub Build Dockehub build status Version

Export sentry project's metrics consistent with the Prometheus exposition formats

Getting Started

Prerequisites

  • python >= 3.7.9
  • Sentry API auth token

    Authentication token permissions: project:read org:read project:releases event:read

Install

pip install -r requirements.txt

Run

export SENTRY_BASE_URL="https://sentry.io/api/0/"
export SENTRY_AUTH_TOKEN="[REPLACE_TOKEN]"
export SENTRY_EXPORTER_ORG="[ORGANIZATION_SLUG]"
python exporter.py

Docker

Run

docker run --name sentry-exporter -e SENTRY_AUTH_TOKEN=[REPLACE_TOKEN] -e SENTRY_EXPORTER_ORG=[ORGANIZATION_SLUG] italux/sentry-prometheus-exporter

Build local image

docker-compose build

Create a .env file

echo SENTRY_BASE_URL="https://sentry.io/api/0/"
echo SENTRY_AUTH_TOKEN="[REPLACE_TOKEN]"
echo SENTRY_EXPORTER_ORG="[organization_slug]"

Start containers

docker-compose up -d

Metrics

  • sentry_open_issue_events: A Number of open issues (aka is:unresolved) per project in the past 1h
  • sentry_issues: Gauge Histogram of open issues split into 3 buckets: 1h, 24h, and 14d
  • sentry_events: Total events counts per project

Metric Configuration

By default all metrics are scraped, however, issue or event-related metrics can be disabled by setting the relevant variable to False:

export SENTRY_SCRAPE_ISSUE_METRICS=False
export SENTRY_SCRAPE_EVENT_METRICS=False

By default, if SENTRY_SCRAPE_ISSUE_METRICS=True or is unset issue metrics are scraped for 1hour, 24hours and 14days. Any of these can be disabled by setting the relevant variable to False:

export SENTRY_ISSUES_1H=False
export SENTRY_ISSUES_24H=False
export SENTRY_ISSUES_14D=False

As with SENTRY_AUTH_TOKEN, all of these variables can be passed in through the docker run -e VAR_NAME=<> command or via the .env file if using Docker Compose.

Samples

Grafana Dashboard Sentry Issues & Events Overview

Prometheus configuration: prometheus.yml

scrape_configs:
  - job_name: 'sentry_exporter'
    static_configs:
    - targets: ['sentry-exporter:9790']
    scrape_interval: 5m
    scrape_timeout: 4m

ℹ️ Important Notes

Limitations

  • Performance: The exporter is serial, if your organization has a high number of issues & events you may experience Context Deadline Exceeded error during a Prometheus scrape

Recomendations & Tips

  • Use scrape_interval: 5m minimum.

This value will be defined by the number of new issues and events
higher number of events will take more time

  • Use a high scrape_timeout for the exporter job

General recomendation is to set scrape_interval - 1 (i.e.: 4m)

  • If the scraping of particular metrics are disabled the values above can be reduced depending on your setup.

📒 Documentation

Sentry Prometheus Exporter documentation

🤝 Contributing

Contributions, issues and feature requests are welcome!

📝 License

Copyright © 2021 Italo Santos.

This project is GNU General Public License v2.0 licensed.

Show your support

Give a ⭐️ if this project helped you!

Author

👤 Italo Santos


This README was generated with by readme-md-generator

About

Export sentry metrics for prometheus

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.9%
  • Dockerfile 1.1%