> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GraphQL API examples

AppSignal provides a [GraphQL API](/api/graphql) that allows you to programmatically query your application data.

On this page, you'll find query examples to help you get started. For write
operations, see the [mutation examples](/api/graphql/mutations) page.

Read the [GraphQL API page](/api/graphql) for more information about the GraphQL endpoint and authentication.

<Warning>
  Reading bulk data — metrics, logs, and traces — through the GraphQL API is
  deprecated. Use the [REST API (V2)](/api/v2/overview) instead, such as
  [metrics](/api/v2/metrics) and [log search](/api/v2/logs). The GraphQL API does
  not expose log lines. The metric examples on this page remain for existing
  integrations.
</Warning>

## Fetch deployments

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  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
        liveForInWords
        liveFor
        exceptionCount
        exceptionRate
        __typename
      }
      __typename
    }
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "appId": "YOUR-APP-ID",
    "limit": 25
  }
  ```
</CodeGroup>

## Fetch incidents for a deploy

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  query ExceptionIncidentsQuery(
    $appId: String!
    $namespaces: [String]
    $markerId: String
    $limit: Int
    $offset: Int
    $state: IncidentStateEnum
    $order: IncidentOrderEnum
  ) {
    app(id: $appId) {
      id
      exceptionIncidents(
        namespaces: $namespaces
        marker: $markerId
        limit: $limit
        state: $state
        offset: $offset
        order: $order
      ) {
        ...ExceptionIncidentRow
        __typename
      }
      __typename
    }
  }

  fragment ExceptionIncidentRow on ExceptionIncident {
    id
    number
    count
    perMarkerCount(marker: $markerId)
    lastOccurredAt
    actionNames
    exceptionName
    state
    namespace
    firstBacktraceLine
    errorGroupingStrategy
    severity
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "appId": "YOUR-APP-ID",
    "markerId": "YOUR-DEPLOY-MARKER-ID",
    "limit": 200
  }
  ```
</CodeGroup>

## Search incidents by tag

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  query Search(
    $organizationSlug: String!
    $query: String
    $namespace: String
    $sampleType: SampleTypeEnum
  ) {
    organization(slug: $organizationSlug) {
      search(query: $query, namespace: $namespace, sampleType: $sampleType) {
        ... on ExceptionSample {
          id
          time
          action
          namespace
          overview {
            key
            value
          }
          exception {
            name
            message
          }
          incident {
            ... on ExceptionIncident {
              number
            }
          }
          app {
            name
            environment
            id
          }
        }
        ... on PerformanceSample {
          id
          appId
          time
          action
          namespace
          duration
          overview {
            key
            value
          }
          incident {
            ... on PerformanceIncident {
              number
            }
          }
          app {
            name
            environment
            id
          }
        }
      }
    }
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "organizationSlug": "YOUR-ORGANIZATION-SLUG", // taken from the organization URL
    "sampleType": "EXCEPTION",
    "query": "tag:value" // replace the word value with the values you are searching for
  }
  ```
</CodeGroup>

The following examples use the legacy GraphQL metrics API and remain here for
existing integrations.

## Fetch error count

<Warning>
  This example uses the deprecated GraphQL metrics API. For new integrations,
  use the REST [metrics list](/api/v2/metrics) endpoint instead.
</Warning>

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  query MetricsListQuery(
    $appId: String!
    $start: DateTime
    $end: DateTime
    $timeframe: TimeframeEnum
    $query: [MetricAggregation!]!
  ) {
    app(id: $appId) {
      id
      metrics {
        list(start: $start, end: $end, query: $query, timeframe: $timeframe) {
          start
          end
          rows {
            name
            tags {
              key
              value
            }
            fields {
              key
              value
            }
          }
        }
      }
    }
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "appId": "YOUR-APP-ID",
    "start": "2021-06-04T13:00:00.000Z", // change this to the date of your preference
    "end": "2021-12-21T14:00:00.000Z",   // change this to the date of your preference
    "query": [
      {
      "name": "transaction_exception_count",
      "tags": [{ "key": "namespace", "value": "*" }],
      "fields": [{ "field": "COUNTER", "aggregate": "SUM" }]
      }
    ]
  }
  ```
</CodeGroup>

## Fetch mean (timeseries)

<Warning>
  This example uses the deprecated GraphQL metrics API. For new integrations,
  use the REST [metrics timeseries](/api/v2/metrics) endpoint instead.
</Warning>

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  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 {
            name
            fields
            tags {
              key
              value
            }
          }
          points {
            timestamp
            values {
              value
            }
          }
        }
      }
    }
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "appId": "YOUR-APP-ID",
    "start": "2022-01-10T11:00:00Z", // Start data and time you want to fetch the Mean for
    "end": "2022-01-10T11:05:00Z",   // End data and time you want to fetch the Mean for
    "query": [
      {
        "name": "transaction_duration",
        "tags": [ // You can add more namespaces here, this example just fetches the Mean for web namespace.
          {
            "key": "namespace",
            "value": "web"
          }
        ],
        "fields": [
          {
            "field": "MEAN"
          }
        ]
      }
    ]
  }
  ```
</CodeGroup>

## Fetch mean (aggregated)

<Warning>
  This example uses the deprecated GraphQL metrics API. For new integrations,
  use the REST [metrics list](/api/v2/metrics) endpoint instead.
</Warning>

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  query MetricAggregationQuery(
    $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 {
              key
              value
            }
            fields {
              key
              value
            }
          }
        }
      }
    }
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "appId": "YOUR-APP-ID",
    "start": "2022-01-10T11:00:00Z", // Start data and time you want to fetch the Mean for
    "end": "2022-01-10T11:05:00Z",   // End data and time you want to fetch the Mean for
    "query": [
      {
        "name": "transaction_duration",
        "tags": [ // You can add more namespaces here, this example just fetches the Mean for web namespace.
          {
            "key": "namespace",
            "value": "web"
          }
        ],
        "fields": [
          {"field":"mean","aggregate":"AVG"}
        ]
      }
    ]
  }
  ```
</CodeGroup>

## Fetch incident with sample

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  query IncidentQuery(
    $appId: String!
    $incidentNumber: Int!
    $sampleId: String
    $timestamp: String
    $timerange: [DateTime]
  ) {
    app(id: $appId) {
      id
      incident(incidentNumber: $incidentNumber) {
        ... on ExceptionIncident {
          ...ExceptionIncident
        }
        ... on PerformanceIncident {
          ...PerformanceIncident
        }
      }
    }
  }
  fragment ExceptionIncident on ExceptionIncident {
    id
    number
    lastOccurredAt
    actionNames
    exceptionName
    notificationFrequency
    state
    namespace
    firstBacktraceLine
    errorGroupingStrategy
    sample(id: $sampleId, timestamp: $timestamp, timerange: $timerange) {
      ...ExceptionSample
    }
  }
  fragment ExceptionSample on ExceptionSample {
    id
    appId
    time
    revision
    action
    namespace
    queueDuration
    originallyRequested
    overview {
      key
      value
    }
    params
    sessionData
    customData
    environment {
      key
      value
    }
    exception {
      name
      message
      backtrace {
        original
        line
        column
        path
        method
        url
        type
        code {
          line
          source
        }
        error {
          class
          message
        }
      }
    }
  }
  fragment PerformanceIncident on PerformanceIncident {
    id
    number
    lastOccurredAt
    actionNames
    state
    notificationFrequency
    notificationThreshold
    namespace
    description
    severity
    sample(id: $sampleId, timestamp: $timestamp, timerange: $timerange) {
      ...PerformanceSample
      __typename
    }
    __typename
  }
  fragment PerformanceSample on PerformanceSample {
    id
    appId
    time
    revision
    action
    namespace
    originallyRequested
    hasNPlusOne
    timelineTruncatedEvents
    overview {
      key
      value
      __typename
    }
    params
    sessionData
    customData
    environment {
      key
      value
      __typename
    }
    duration
    queueDuration
    timeline {
      ...TimelineEvent
      __typename
    }
    version
    __typename
  }
  fragment TimelineEvent on TimelineEvent {
    action
    duration
    childDuration
    group
    name
    payload {
      name
      body
      __typename
    }
    time
    end
    digest
    count
    level
    allocationCount
    childAllocationCount
    __typename
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "appId": "YOUR-APP-ID",
    "incidentNumber": 42,
    "sampleId": "SAMPLE-ID-STRING", // optional
    "timestamp": "2026-06-22T12:00:00Z", // optional
    "timerange": ["2026-06-22T00:00:00Z", "2026-06-22T23:59:59Z"] // optional
  }
  ```
</CodeGroup>

## Fetch uptime monitors and their alerts

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  query uptimeMonitorsQuery($appId: String!) {
    app(id: $appId) {
      id
      uptimeMonitors {
        ...UptimeMonitor
      }
    }
  }

  fragment UptimeMonitor on UptimeMonitor {
    id
    name
    url
    description
    notifierIds
    warmupDuration
    checkBodyContent
    regions
    headers {
      key
      value
    }
    alerts {
      ...Alert
    }
    statusPages {
      ...StatusPage
    }
  }

  fragment Alert on Alert {
    id
    state
    message
    metricDigest
    createdAt
    openedAt
    resolvedAt
    closedAt
    timeframeStartAt
    timeframeEndAt
    lastValue
    peakValue
    mean
    tags {
      key
      value
    }
  }

  fragment StatusPage on StatusPage {
    id
    title
    subdomain
    hostname
    description
    threshold
    uptimeMonitorIds
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "appId": "YOUR-APP-ID"
  }
  ```
</CodeGroup>

## Fetch uptime monitor status

<Warning>
  This example uses the deprecated GraphQL metrics API. For new integrations,
  use the REST [metrics timeseries](/api/v2/metrics) endpoint instead.
</Warning>

### Query

<CodeGroup>
  ```graphql GraphQL theme={null}
  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
            name
            fields
            tags {
              key
              value
            }
          }
          points {
            timestamp
            values {
              key
              value
            }
          }
        }
      }
    }
  }
  ```
</CodeGroup>

### Query variables

<CodeGroup>
  ```graphql GraphQL theme={null}
  {
    "appId": "YOUR-APP-ID",
    "timeframe": "R1H", // for example: R1H, R4H, R8H, R12H, R24H, R48H, R7D, or R30D
    "query": [
      {
        "name": "uptime_monitor_error_count",
        "tags": [
          {
            "key": "name",
            "value": "NAME-OF-UPTIME-MONITOR"
          },
          {
            "key": "region",
            "value": "*" // You can filter this to a specific region.
          }
        ],
        "fields": [
          {
            "field": "COUNTER"
          }
        ]
      }
    ]
  }
  ```
</CodeGroup>
