Sign inSign up

dptsi/sentry-prometheus-exporter

By dptsi

•Updated 2 months ago

Image
0

138

dptsi/sentry-prometheus-exporter repository overview

Important

**Maintenance Notice**

This project is currently not actively maintained, and responses to issues or pull requests may be delayed for several months. Please consider this when using the project and feel free to contribute via pull requests, which will be reviewed as time permits. Thank you for your understanding!

⁠Welcome to Sentry Prometheus Exporter šŸ‘‹

License: GNU General Public License v2.0 Dockerhub Build Dockerhub 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]"

# optionally configure collector thread pool count
echo MAX_COLLECTOR_WORKER=25

# optionally change web server worker's timeout
echo GUNICORN_CMD_ARGS="--timeout 60 -w 4 -b 0.0.0.0:9790"

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
  • sentry_rate_limit_events_sec: Rate limit of errors per second accepted for a project.
⁠Project Configuration

By default, sentry's API will be polled to retrieve all projects. If you wish for specific projects to be scraped, you can do the following:

export SENTRY_EXPORTER_PROJECTS="project1,project2,project3"
⁠Metric Configuration

Excepting rate-limit-events metric, 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

Enable rate-limit-events metric by setting the relevant variable to True:

export SENTRY_SCRAPE_RATE_LIMIT_METRICS=True

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.

⁠Basic Authentication

Security is always a concern and metrics can contain sensitive information that you'd like to protect and HTTP Basic authentication⁠ is the most simple standard that uses fields in the HTTP header to restrict access to a specific URL.

To enable the basic authentication mechanism on Sentry Prometheus Exporter you just need to export the SENTRY_EXPORTER_BASIC_AUTH and configure the credentials as follows

⁠Credentials configurations
Environment variableValue typeDefault valuePurpose
SENTRY_EXPORTER_BASIC_AUTHBooleanFalseEnable basic authentication
SENTRY_EXPORTER_BASIC_AUTH_USERStringprometheusBasic authentication username
SENTRY_EXPORTER_BASIC_AUTH_PASSStringprometheusBasic authentication password

Once enable, the /metrics/ page will prompt username & password window

⁠Prometheus configuration

If you enable the exporter HTTP basic authentication you'l need to configure prometheus scrape to pass the username & password defined on every scrape, please check prometheus <scrape_config>⁠ for more information.

basic_auth:
  [ username: <string> ]
  [ password: <secret> ]

⁠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

⁠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

  • Sentry API retry calls: The Sentry API limits the rate of requests to 3 per second, so the exporter retries on an HTTP exception.

    You can tweak retry settings with environment variables, though default settings should work:

    Environment variableValue typeDefault valuePurpose
    SENTRY_RETRY_TRIESInteger3How many retries should be made in case of an exception
    SENTRY_RETRY_DELAYFloat1How many seconds to wait between retries
    SENTRY_RETRY_MAX_DELAYFloat10Max delay to wait between retries
    SENTRY_RETRY_BACKOFFFloat2Multiplier applied to delay between attempts
    SENTRY_RETRY_JITTERFloat0.5Extra seconds added to delay between attempts
⁠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⁠

Tag summary

Content type

Image

Digest

sha256:c1d6ae328…

Size

48 MB

Last updated

2 months ago

docker pull dptsi/sentry-prometheus-exporter:v0.10.0