Skip to content

Instantly share code, notes, and snippets.

View shairyar's full-sized avatar

shairyar shairyar

View GitHub Profile
@shairyar
shairyar / query.gql
Created June 24, 2021 15:23
uptime Response times per region
query MetricTimeseriesQuery($appId: String!, $start: DateTime, $end: DateTime, $timeframe: TimeframeEnum, $query: [MetricTimeseries]) {
app(id: $appId) {
id
metrics {
timeseries(start: $start, end: $end, timeframe: $timeframe,query: $query) {
start
end
resolution
keys {
digest
@shairyar
shairyar / query.gql
Created June 24, 2021 15:24
Uptime monitors
query MetricTimeseriesQuery($appId: String!, $start: DateTime, $end: DateTime, $timeframe: TimeframeEnum, $query: [MetricTimeseries]) {
app(id: $appId) {
id
metrics {
timeseries(start: $start, end: $end, timeframe: $timeframe, query: $query) {
start
end
resolution
keys {
digest
@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
@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 / IncidentQuery.gql
Last active October 13, 2021 09:41
Fetching error incident from AppSignal using GraphQL
query IncidentQuery($appId: String!, $incidentNumber: Int!, $sampleId: String, $timestamp: String, $timerange: [DateTime]) {
app(id: $appId) {
id
incident(incidentNumber: $incidentNumber) {
... on ExceptionIncident {
...ExceptionIncident
__typename
}
__typename
}
@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 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
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 / 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 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 {