Skip to content

Instantly share code, notes, and snippets.

View shairyar's full-sized avatar

shairyar shairyar

View GitHub Profile
@shairyar
shairyar / fetch_incident.gql
Last active July 21, 2023 07:51
GraphQL query to fetch incidents logged in AppSignal
query PaginatedExceptionIncidentsQuery($appId: String!, $namespaces: [String], $markerId: String, $limit: Int, $offset: Int, $state: IncidentStateEnum, $order: IncidentOrderEnum) {
app(id: $appId) {
id
paginatedExceptionIncidents(
namespaces: $namespaces
marker: $markerId
limit: $limit
state: $state
offset: $offset
order: $order
@shairyar
shairyar / uptime_monitor.gql
Last active May 17, 2023 12:21
Create uptime monitor in AppSignal using GraphQL API
mutation createUptimeMonitorMutation($appId: String!, $uptimeMonitor: UptimeMonitorInput!) {
createUptimeMonitor(appId: $appId, uptimeMonitor: $uptimeMonitor) {
...UptimeMonitor
__typename
}
}
fragment UptimeMonitor on UptimeMonitor {
id
name
@shairyar
shairyar / CustomMetricsDashboardsDefinitionQuery.gql
Created April 13, 2023 08:37
Export AppSignal dashboard metrics
query CustomMetricsDashboardsDefinitionQuery($appId: String!) {
app(id: $appId) {
id
dashboards {
...Dashboard
__typename
}
__typename
}
}
query PaginatedMetricsListQuery($appId: String!, $start: DateTime, $end: DateTime, $timeframe: TimeframeEnum, $query: [MetricAggregation!]!) {
app(id: $appId) {
id
metrics {
list(start: $start, end: $end, timeframe: $timeframe, query: $query) {
start
end
rows {
name
tags {
@shairyar
shairyar / transaction_allocation_count.gql
Created July 25, 2022 12:43
Query to help fetch object count for each action
query PaginatedMetricsListQuery(
$appId: String!,
$start: DateTime,
$end: DateTime,
$timeframe: TimeframeEnum,
$query: [MetricAggregation!]!
$limit: Int,
$offset: Int
){
app(id: $appId) {
query IncidentQuery($appId: String!, $incidentNumber: Int!, $sampleId: String, $timestamp: String, $timerange: [DateTime]) {
app(id: $appId) {
id
incident(incidentNumber: $incidentNumber) {
... on ExceptionIncident {
...ExceptionIncident
logbook {
...Logbook
__typename
}
@shairyar
shairyar / appsignal.rb
Last active December 24, 2021 06:36
Sending error to AppSignal using the frontend API
# https://docs.appsignal.com/api/public-endpoint/errors.html#body-parameters
require "uri"
require "json"
require "net/http"
url = URI("https://appsignal-endpoint.net/errors?api_key=FRONTEND-API-KEY")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
@shairyar
shairyar / MarkersIndexQuery.gql
Created October 15, 2021 10:04
List all revision
query MarkersIndexQuery($appId: String!, $limit: Int, $offset: Int, $start: DateTime, $end: DateTime) {
app(id: $appId) {
id
deployMarkers(limit: $limit, offset: $offset, start: $start, end: $end) {
id
createdAt
shortRevision
revision
gitCompareUrl
user
@shairyar
shairyar / appsignal.rb
Last active September 28, 2021 11:22
Rake task initializer
if ENV["APPSIGNAL_PUSH_API_KEY"]
require "rake/task"
class AppsignalRakeHelper
class << self
# Mark a Rake task that it should wait for AppSignal to transmit all the data
# when the task is done. It should only do this on Heroku.
def wait_on_exit
return unless ENV["DYNO"] # Only activate on Heroku
@shairyar
shairyar / Search.gql
Last active September 17, 2021 10:31
Search incidents
query Search(
$organizationSlug: String!
$query: String
$namespace: String
$sampleType: SampleTypeEnum
) {
organization(slug: $organizationSlug) {
search(
query: $query
namespace: $namespace