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

# Get Incidents for a Validator

> Query the incidents of a specific validator by its resource name using the Validio SDK.

## Overview

When you know which validator you want incidents for, you can query that validator by its resource name and expand the result to include all of its incidents, without using the `incidentGroups` query.

## Steps

**1. Construct the query**

Write a query that calls `validatorByResourceName`, with variables for `namespaceId` and `resourceName`.

**2. Execute the query**

Pass the query and set the variable values.

**3. Iterate over the result**

Iterate over each incident and print its value and how much it deviated.

## Full code sample

```python title="Python" theme={null}
import os

from validio_sdk.client import Client


async def example(validator_name: str = os.environ["EXAMPLE_VALIDATOR_NAME"]):
    client = Client()
    query = """
    query ValidatorByResourceName(
      $namespaceId: NamespaceId!,
      $resourceName: String!
    ) {
      validatorByResourceName(
        namespaceId: $namespaceId,
        resourceName: $resourceName
      ) {
        name
        incidents {
          value
          deviation
        }
      }
    }
    """
    result = await client.execute(
        query,
        variable_values={
            "namespaceId": os.environ["EXAMPLE_NAMESPACE_ID"],
            "resourceName": validator_name,
        },
    )

    for incident in result["validatorByResourceName"]["incidents"]:
        print(f'{incident["value"]} - {incident["deviation"]}')
```

## Example response

```json title="JSON" theme={null}
{
  "validatorByResourceName": {
    "name": "mean_of_age",
    "incidents": [
      {
        "value": 10.1,
        "deviation": 2.4
      },
      {
        "value": 10.1,
        "deviation": 2.4
      }
    ]
  }
}
```
