steampipe plugin install sentry

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_created
from
sentry_metric_alert;
select
id,
name,
owner,
organization_slug,
project_slug,
aggregate,
data_set,
date_created
from
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_created
from
sentry_metric_alert
where
project_slug = 'go';
select
id,
name,
owner,
organization_slug,
project_slug,
aggregate,
data_set,
date_created
from
sentry_metric_alert
where
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_created
from
sentry_metric_alert as a,
sentry_team as t
where
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 actions
from
sentry_metric_alert,
jsonb_array_elements(triggers) as t
where
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 actions
from
sentry_metric_alert,
json_each(triggers) as t
where
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_created
from
sentry_metric_alert
where
date_created <= now() - interval '1 month';
select
id,
name,
owner,
organization_slug,
project_slug,
aggregate,
data_set,
date_created
from
sentry_metric_alert
where
date_created <= datetime('now', '-1 month');

Schema for sentry_metric_alert

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
aggregatetextThe aggregation criteria to apply.
data_settextThe Sentry metric alert category.
date_createdtimestamp with time zoneThe creation timestamp of the metric alert.
environmenttextPerform metric alert rule in a specific environment.
event_typesjsonbThe events type of dataset.
idtext=The ID of this metric alert.
nametextThe metric alert name.
organization_slugtext=The slug of the organization the metric alert belongs to.
ownertextSpecifies the owner ID of this metric alert rule.
project_slugtext=The slug of the project the metric alert belongs to.
projectsjsonbThe projects for which the metric alert is created.
querytextThe query filter to apply.
resolve_thresholddouble precisionThe value at which the metric alert rule resolves.
task_uuidtextThe UUID of the async task that can be spawned to create the metric alert.
threshold_typebigintThe type of threshold.
time_windowdouble precisionThe period to evaluate the metric alert rule in minutes.
titletextTitle of the resource.
triggersjsonbRepresents 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