Giter Site home page Giter Site logo

ujamii / prometheus-sentry-exporter Goto Github PK

View Code? Open in Web Editor NEW
35.0 5.0 11.0 45 KB

Exports sentry project metrics for prometheus.

License: MIT License

PHP 60.03% Dockerfile 7.80% Smarty 32.17%
prometheus prometheus-exporter sentry sentry-onpremise openmetrics

prometheus-sentry-exporter's People

Contributors

dependabot[bot] avatar killmeplz avatar marcindulak avatar mgrundkoetter avatar ryansiu1995 avatar sergeylanzman avatar victorcfonseca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

prometheus-sentry-exporter's Issues

Some labels aren't idiomatic

Labels like issue_first_seen and issue_last_seen are a poor use of labels, because

  1. Having a very high cardinality for labels is an prometheus antipattern
  2. You never want to show a graph for an issue "where issue_first_seen is 2020-03-23T12:00:06.430Z", so you shouldn't report it as a label

This, instead, should be a separate metric (e.g. age since last/first seen in seconds), or should be ignored, or at least reduced to "year-month" format, for example if someone wants to know how often old issues resurface.

Improve the readme.md adding examples when use the sentry cloud instead sentry self hosted.

I just added some informations on the readme.md that were useful for me. Maybe it may help other people.

Exporter for sentry data in prometheus format

This package uses the Sentry web api to query for some statistics and outputs them in OpenMetrics format to be scraped by prometheus.

You can also fire it up as a docker container.

Usage

Using this exporter throught with Composer or Docker, you will need the hostname of your sentry installation and an auth token, which you can create via https://<YOUR-SENTRY-HOST>/api/ if you're working with the Sentry self hosted. If you're working with Sentry cloud, you will need to create the token via https://sentry.io/settings/account/api/auth-tokens/.

with Composer

Installation

composer req ujamii/prometheus-sentry-exporter

Usage in your custom file

require_once 'vendor/autoload.php';

$sentryBase = 'https://<YOUR-SENTRY-HOST>/api/0/';
$token      = '<AUTH-TOKEN>'; // get from https://<YOUR-SENTRY-HOST>/api/

$exporter = new \Ujamii\OpenMetrics\Sentry\SentryExporter($token, $sentryBase);
$exporter->run();

with Docker

The image is based on php:7.2-apache and thus exposes data on port 80 by default. Assuming you fire this up with -p 80:80 on localhost, you can see the metrics on http://localhost/metrics.

Configuration is done with 3 env variables: SENTRY_HOST, AUTH_TOKEN and HTTP_PROTO.
The first 2 are mandatory, HTTP_PROTO is optional and set to https by default. If you're working with the Sentry Cloud, your SENTRY_HOST variable must be "sentry.io"

docker run -d --name sentry-prometheus -e SENTRY_HOST=sentry.foobar.com -e AUTH_TOKEN=foobarlongtoken -p "80:80" ujamii/prometheus-sentry-exporter

View on Docker Hub

Output

The script will generate something like:

# TYPE sentry_open_issue_events gauge
# HELP sentry_open_issue_events Number of events for one unresolved issue.
sentry_open_issue_events{project_slug="foobar", project_name="Foo Bar", issue_first_seen="2019-02-19T11:24:52Z", issue_last_seen="2019-02-28T09:17:47Z", issue_logger="php", issue_type="error", issue_link="https://<SENTRY-HOST>/<ORGANIZATION>/<PROJECT>/issues/1797/", issue_level="error"} 16.000000
...

A support in helm chart

Hi, thanks for the building out this exporter.
Prometheus is now mainly used in Kubernetes world.
Could you mind create a helm chart template for us to deploy this in a easier manner?
Thank you!

Skip tls verify

Hello.
I have s self-sighnet sertificate on sentry server and I get this error while trying to use exporter

Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: self signed certificate in certificate chain (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:201 Stack trace: #0 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(155): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array) #1 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(105): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #2 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory)) #3 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(28): GuzzleHttp\Handler\CurlHandler->__in in /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 201

Can I skip tls verify some how?

Unhelpful error "Uncaught TypeError"

When I try to curl the scraper/metrics/, I get

<br />
<b>Fatal error</b>:  Uncaught TypeError: Return value of Ujamii\OpenMetrics\Sentry\SentryExporter::getJson() must be of the type array, null returned in /var/www/html/src/SentryExporter.php:108
Stack trace:
#0 /var/www/html/src/SentryExporter.php(98): Ujamii\OpenMetrics\Sentry\SentryExporter-&gt;getJson(Object(GuzzleHttp\Psr7\Response))
#1 /var/www/html/src/SentryExporter.php(55): Ujamii\OpenMetrics\Sentry\SentryExporter-&gt;getProjects()
#2 /var/www/html/metrics/index.php(7): Ujamii\OpenMetrics\Sentry\SentryExporter-&gt;run()
#3 {main}
  thrown in <b>/var/www/html/src/SentryExporter.php</b> on line <b>108</b><br />

To add to the confusion, there is nothing in the server log, and this returns http 200.

API token is configured, and the URL format seems correct. When I curl the Sentry API endpoint with the same token, I get a normal-seeming, valid JSON response.

Using the official docker image:

ujamii/prometheus-sentry-exporter latest 1a7d291064ac 9 months ago 523MB

Invalid token

Hello. I am trying to run this exporter, but get "Ivalid token" error. I get this error both on sentry.io and our sentry.
изображение
Снимок экрана от 2023-10-20 11-37-40

Issue with Sentry Rate Limit

there is a problem when i tried to add the exporter to prometheus!
this is what i got after 1 minute
Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: GET http://192.168.30.160:9000/api/0/projects/sentry/api/issues/ resulted in a 429 Too Many Requests response: {"detail":"You are attempting to use this endpoint too quickly. Limit is 3/1s"} in /var/www/html/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /var/www/html/vendor/guzzlehttp/guzzle/src/Middleware.php(69): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL) #1 /var/www/html/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /var/www/html/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL) #3 /var/www/html/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise{closure}() #4 /var/www/html/vendor/guzzlehttp/promises/src/Promise. in /var/www/html/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

how can i fix this? it seems a sentry rate limit restriction , but there is no configuration for it!

'issue_logger' is NULL

Accessing http://localhost/metrics/ gives:

Fatal error: Uncaught TypeError: Argument 2 passed to OpenMetricsPhp\Exposition\Text\Types\Label::fromNameAndValue() must be of the type string, null given, called in /var/www/html/src/SentryExporter.php on line 65 and defined in /var/www/html/vendor/openmetrics-php/exposition-text/src/Types/Label.php:44 Stack trace: #0 /var/www/html/src/SentryExporter.php(65): OpenMetricsPhp\Exposition\Text\Types\Label::fromNameAndValue('issue_logger', NULL) #1 /var/www/html/metrics/index.php(6): Ujamii\OpenMetrics\Sentry\SentryExporter->run() #2 {main} thrown in /var/www/html/vendor/openmetrics-php/exposition-text/src/Types/Label.php on line 44

Label::fromNameAndValue('issue_logger', $issue->logger),

question about non-continuous metrics

I'm trying to calculate rates of errors based on sentry_open_issue_events, but the metrics is non-continuous. I guess due to this I'm unable to calculate rates, the closest thing to a rate I got is topk(3, sentry_open_issue_events - ignoring(issue_last_seen, instance, pod) sentry_open_issue_events offset 10m), but this is still non-continuous. Do you have an opinion about this? What is you use case for sentry_open_issue_events?

Screenshot from 2019-05-20 16-38-23_redacted

It looks like the problem be due to the issue_last_seen label. Every time a new series is created for a new issue_last_seen. After removing issue_last_seen

Label::fromNameAndValue('issue_last_seen', $issue->lastSeen),
I can calculate rates, e.g. topk(3, rate(sentry_open_issue_events{project_slug="my-service"}[5m])) > 0, but when I click a couple of time on prometheus Console sometimes I'm getting "no data" for even a simple topk(3, sentry_open_issue_events{project_slug="my-service"}) query. Could you verify this, and possibly remove issue_last_seen?

Specify the project names that I want to get metrics.

If there are many projects in Sentry, the process of collecting metrics can take a long time. In some cases, it may be interesting to point out only projects that have already been mapped and that need special attention. In addition, there is apparently a limit of 100 in the counters, where I cannot see more than 100 issues of the same project and not more than 100 projects.

I am grateful if you can help me and if I develop something locally, I share with you to evaluate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.