Table: sentry_metric_alert - Query Sentry Metric Alerts using SQL
Sentry is an open-source error tracking system that helps developers monitor and fix crashes in real time. It provides complete stack traces, tells you how many times an error occurred, and shows the affected user count. A Metric Alert in Sentry is a rule that triggers notifications when a specific metric (like the count of a certain type of event) goes beyond a defined threshold.
Table Usage Guide
The sentry_metric_alert
table provides insights into Metric Alerts within Sentry's error tracking system. As a developer or DevOps engineer, explore alert-specific details through this table, including alert rules, their triggers, and associated metadata. Utilize it to uncover information about alerts, such as those triggered by certain types of events, the thresholds defined for alerts, and the actions taken when alerts are triggered.
Examples
Basic info
Explore which metric alerts have been created within your organization, allowing you to identify instances where specific alerts may need to be updated or adjusted. This is particularly useful for maintaining optimal performance and ensuring timely responses to any issues or anomalies.
select id, name, owner, organization_slug, project_slug, aggregate, data_set, date_createdfrom sentry_metric_alert;
select id, name, owner, organization_slug, project_slug, aggregate, data_set, date_createdfrom sentry_metric_alert;
List alerts for a particular project
Explore which alerts are associated with a specific project to better manage and respond to issues. This can provide crucial insights to maintain project health and efficiency.
select id, name, owner, organization_slug, project_slug, aggregate, data_set, date_createdfrom sentry_metric_alertwhere project_slug = 'go';
select id, name, owner, organization_slug, project_slug, aggregate, data_set, date_createdfrom sentry_metric_alertwhere project_slug = 'go';
List alerts owned by a particular team
Explore which alerts are managed by a specific team to better understand the distribution of responsibilities and ownership within your organization. This can be particularly useful in large organizations where multiple teams are managing different sets of alerts.
select a.id, a.name, a.owner, a.organization_slug, a.project_slug, a.aggregate, a.data_set, a.date_createdfrom sentry_metric_alert as a, sentry_team as twhere t.id = split_part(a.owner, ':', 2) and t.name = 'Team A';
Error: SQLite does not support split_part function.
Show list of triggers of a particular alert
Explore the different triggers associated with a specific alert to understand their thresholds and actions. This can help in assessing the alert's sensitivity and response strategy.
select t ->> 'id' as id, t ->> 'alertRuleId' as alert_rule_id, t ->> 'label' as label, t ->> 'thresholdType' as threshold_type, t ->> 'alertThreshold' as alert_threshold, t ->> 'resolveThreshold' as resolve_threshold, t ->> 'dateCreated' as date_created, jsonb_pretty(t -> 'actions') as actionsfrom sentry_metric_alert, jsonb_array_elements(triggers) as twhere name = 'alert-metric';
select json_extract(t.value, '$.id') as id, json_extract(t.value, '$.alertRuleId') as alert_rule_id, json_extract(t.value, '$.label') as label, json_extract(t.value, '$.thresholdType') as threshold_type, json_extract(t.value, '$.alertThreshold') as alert_threshold, json_extract(t.value, '$.resolveThreshold') as resolve_threshold, json_extract(t.value, '$.dateCreated') as date_created, t.value as actionsfrom sentry_metric_alert, json_each(triggers) as twhere name = 'alert-metric';
List alerts older than a month
Explore which alerts have been active for longer than a month to assess areas that may require attention or review. This can help identify lingering issues within your project or organization that have not been resolved.
select id, name, owner, organization_slug, project_slug, aggregate, data_set, date_createdfrom sentry_metric_alertwhere date_created <= now() - interval '1 month';
select id, name, owner, organization_slug, project_slug, aggregate, data_set, date_createdfrom sentry_metric_alertwhere date_created <= datetime('now', '-1 month');
Schema for sentry_metric_alert
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
aggregate | text | The aggregation criteria to apply. | |
data_set | text | The Sentry metric alert category. | |
date_created | timestamp with time zone | The creation timestamp of the metric alert. | |
environment | text | Perform metric alert rule in a specific environment. | |
event_types | jsonb | The events type of dataset. | |
id | text | = | The ID of this metric alert. |
name | text | The metric alert name. | |
organization_slug | text | = | The slug of the organization the metric alert belongs to. |
owner | text | Specifies the owner ID of this metric alert rule. | |
project_slug | text | = | The slug of the project the metric alert belongs to. |
projects | jsonb | The projects for which the metric alert is created. | |
query | text | The query filter to apply. | |
resolve_threshold | double precision | The value at which the metric alert rule resolves. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
task_uuid | text | The UUID of the async task that can be spawned to create the metric alert. | |
threshold_type | bigint | The type of threshold. | |
time_window | double precision | The period to evaluate the metric alert rule in minutes. | |
title | text | Title of the resource. | |
triggers | jsonb | Represents a metric alert trigger. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- sentry
You can pass the configuration to the command with the --config
argument:
steampipe_export_sentry --config '<your_config>' sentry_metric_alert