ujamii / prometheus-sentry-exporter Goto Github PK
View Code? Open in Web Editor NEWExports sentry project metrics for prometheus.
License: MIT License
Exports sentry project metrics for prometheus.
License: MIT License
Labels like issue_first_seen
and issue_last_seen
are a poor use of labels, because
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.
I just added some informations on the readme.md that were useful for me. Maybe it may help other people.
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.
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/
.
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();
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
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
...
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!
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?
Hi all, do you have dashboards for grafana? Thanks for reply
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->getJson(Object(GuzzleHttp\Psr7\Response))
#1 /var/www/html/src/SentryExporter.php(55): Ujamii\OpenMetrics\Sentry\SentryExporter->getProjects()
#2 /var/www/html/metrics/index.php(7): Ujamii\OpenMetrics\Sentry\SentryExporter->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
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!
Using https://symfony.com/doc/current/components/dotenv.html, it would be possible to inject the host and auth token. We can then create a Dockerfile and publish a ready-to-use docker image.
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
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
?
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
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
?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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.