Grafana Recording Rules API

The recording_rules API from Grafana — 4 operation(s) for recording_rules.

GitHub OpenAPI
Business capability
Observability Management BC-4220.20

Operations 8

Each operation below carries the questions people ask an LLM about it and the instructions they give an agent to run it. Generated by API Evangelist overlay

GET /recording-rules List recording rules · Lists all rules in the database: active or deleted #
Ask an LLM
“Which recording rules are defined in my Grafana instance?”
“Can I see both active and deleted recording rules?”
Tell an agent
List all recording rules.
Show every recording rule in the database.
PUT /recording-rules Update a recording rule · Update the active status of a rule #
Ask an LLM
“How do I change the active status of an existing recording rule?”
“Can I rename a recording rule or change its interval?”
Tell an agent
Set recording rule {id} active to {active}.
Update recording rule {id} with interval {interval}.
POST /recording-rules Create a recording rule · Create a recording rule that is then registered and started #
Ask an LLM
“How do I create a new recording rule that starts automatically?”
“Can I record Prometheus metrics into a specific data source as a recording rule?”
Tell an agent
Create recording rule {name} with queries {queries}.
Create recording rule {name} on data source {dest_data_source_uid} with interval {interval}.
POST /recording-rules/test Test a recording rule definition · Test a recording rule #
Ask an LLM
“Can I test a recording rule definition before creating it?”
“What does a recording rule return when I test it against a range?”
Tell an agent
Test recording rule definition {queries} over range {range}.
Validate recording rule {name} with queries {queries}.
GET /recording-rules/writer Get the recording rule remote write target · Return the prometheus remote write target #
Ask an LLM
“Where are recording rules being written to?”
“What remote write path does the recording rule target use?”
Tell an agent
Show the recording rule remote write target.
Get the Prometheus remote write path for recording rules.
POST /recording-rules/writer Create a recording rule remote write target · Create a remote write target #
Ask an LLM
“How do I point recording rules at a Prometheus remote write endpoint?”
“Why does creating a recording rule write target fail if no Prometheus data source is configured?”
Tell an agent
Create a recording rule write target to {remote_write_path} on data source {data_source_uid}.
Register remote write target {id} for recording rules.
DELETE /recording-rules/writer Delete the recording rule remote write target · Delete the remote write target #
Ask an LLM
“How do I stop recording rules from being written anywhere?”
“Can I remove the recording rule remote write target?”
Tell an agent destructive · confirm first
Delete the recording rule remote write target.
Remove the recording rules write target.
DELETE /recording-rules/{recordingRuleID} Delete a recording rule · Delete removes the rule from the registry and stops it #
Ask an LLM
“How do I stop and remove a recording rule?”
“Does deleting a recording rule stop it from running?”
Tell an agent destructive · confirm first
Delete recording rule {recordingRuleID}.
Remove recording rule {recordingRuleID} from the registry.

Documentation

📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/
📖
Authentication
https://grafana.com/docs/grafana/latest/developers/http_api/authentication/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/dashboard/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/dashboard_versions/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/dashboard_permissions/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/dashboard_public/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/folder/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/folder_dashboard_search/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/folder_permissions/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/data_source/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/datasource_permissions/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/datasource_lbac_rules/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/annotations/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/org/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/user/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/team/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/team_sync/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/preferences/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/access_control/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/sso-settings/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/admin/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/licensing/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/reporting/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/query_and_resource_caching/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/library_element/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/correlations/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/snapshot/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/short_url/
📖
Documentation
https://grafana.com/docs/grafana/latest/developers/http_api/query_history/

Specifications

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/grafana-com:grafana-com-recording-rules-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

grafana-com-recording-rules-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  description: 'The Grafana backend exposes an HTTP API, the same API is used by the frontend to do

    everything from saving dashboards, creating users and updating data sources.'
  title: Grafana HTTP API. Recording Rules API
  contact:
    name: Grafana Labs
    url: https://grafana.com
    email: hello@grafana.com
  version: 0.0.1
servers:
- url: /api
security:
- basic: []
- api_key: []
tags:
- name: recording_rules
paths:
  /recording-rules:
    get:
      tags:
      - recording_rules
      summary: 'Lists all rules in the database: active or deleted'
      operationId: listRecordingRules
      responses:
        '200':
          $ref: '#/components/responses/listRecordingRulesResponse'
        '401':
          $ref: '#/components/responses/unauthorisedError'
        '403':
          $ref: '#/components/responses/forbiddenError'
        '404':
          $ref: '#/components/responses/notFoundError'
        '500':
          $ref: '#/components/responses/internalServerError'
    put:
      tags:
      - recording_rules
      summary: Update the active status of a rule
      operationId: updateRecordingRule
      responses:
        '200':
          $ref: '#/components/responses/recordingRuleResponse'
        '401':
          $ref: '#/components/responses/unauthorisedError'
        '403':
          $ref: '#/components/responses/forbiddenError'
        '404':
          $ref: '#/components/responses/notFoundError'
        '500':
          $ref: '#/components/responses/internalServerError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordingRuleJSON'
        required: true
    post:
      tags:
      - recording_rules
      summary: Create a recording rule that is then registered and started
      operationId: createRecordingRule
      responses:
        '200':
          $ref: '#/components/responses/recordingRuleResponse'
        '401':
          $ref: '#/components/responses/unauthorisedError'
        '403':
          $ref: '#/components/responses/forbiddenError'
        '404':
          $ref: '#/components/responses/notFoundError'
        '500':
          $ref: '#/components/responses/internalServerError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordingRuleJSON'
        required: true
  /recording-rules/test:
    post:
      tags:
      - recording_rules
      summary: Test a recording rule
      operationId: testCreateRecordingRule
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '401':
          $ref: '#/components/responses/unauthorisedError'
        '403':
          $ref: '#/components/responses/forbiddenError'
        '404':
          $ref: '#/components/responses/notFoundError'
        '422':
          $ref: '#/components/responses/unprocessableEntityError'
        '500':
          $ref: '#/components/responses/internalServerError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RecordingRuleJSON'
        required: true
  /recording-rules/writer:
    get:
      tags:
      - recording_rules
      summary: Return the prometheus remote write target
      operationId: getRecordingRuleWriteTarget
      responses:
        '200':
          $ref: '#/components/responses/recordingRuleWriteTargetResponse'
        '401':
          $ref: '#/components/responses/unauthorisedError'
        '403':
          $ref: '#/components/responses/forbiddenError'
        '404':
          $ref: '#/components/responses/notFoundError'
        '500':
          $ref: '#/components/responses/internalServerError'
    post:
      description: It returns a 422 if there is not an existing prometheus data source configured.
      tags:
      - recording_rules
      summary: Create a remote write target
      operationId: createRecordingRuleWriteTarget
      responses:
        '200':
          $ref: '#/components/responses/recordingRuleWriteTargetResponse'
        '401':
          $ref: '#/components/responses/unauthorisedError'
        '403':
          $ref: '#/components/responses/forbiddenError'
        '404':
          $ref: '#/components/responses/notFoundError'
        '422':
          $ref: '#/components/responses/unprocessableEntityError'
        '500':
          $ref: '#/components/responses/internalServerError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PrometheusRemoteWriteTargetJSON'
        required: true
    delete:
      tags:
      - recording_rules
      summary: Delete the remote write target
      operationId: deleteRecordingRuleWriteTarget
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '401':
          $ref: '#/components/responses/unauthorisedError'
        '403':
          $ref: '#/components/responses/forbiddenError'
        '404':
          $ref: '#/components/responses/notFoundError'
        '500':
          $ref: '#/components/responses/internalServerError'
  /recording-rules/{recordingRuleID}:
    delete:
      tags:
      - recording_rules
      summary: Delete removes the rule from the registry and stops it
      operationId: deleteRecordingRule
      parameters:
      - name: recordingRuleID
        in: path
        required: true
        schema:
          type: integer
          format: int64
      responses:
        '200':
          $ref: '#/components/responses/okResponse'
        '401':
          $ref: '#/components/responses/unauthorisedError'
        '403':
          $ref: '#/components/responses/forbiddenError'
        '404':
          $ref: '#/components/responses/notFoundError'
        '500':
          $ref: '#/components/responses/internalServerError'
components:
  schemas:
    ErrorResponseBody:
      type: object
      required:
      - message
      properties:
        error:
          description: Error An optional detailed description of the actual error. Only included if running in developer mode.
          type: string
        message:
          description: a human readable version of the error
          type: string
        status:
          description: 'Status An optional status to denote the cause of the error.


            For example, a 412 Precondition Failed error may include additional information of why that error happened.'
          type: string
    SuccessResponseBody:
      type: object
      properties:
        message:
          type: string
    PrometheusRemoteWriteTargetJSON:
      type: object
      properties:
        data_source_uid:
          type: string
        id:
          type: string
        remote_write_path:
          type: string
    RecordingRuleJSON:
      description: RecordingRuleJSON is the external representation of a recording rule
      type: object
      properties:
        active:
          type: boolean
        count:
          type: boolean
        description:
          type: string
        dest_data_source_uid:
          type: string
        id:
          type: string
        interval:
          type: integer
          format: int64
        name:
          type: string
        prom_name:
          type: string
        queries:
          type: array
          items:
            type: object
            additionalProperties: {}
        range:
          type: integer
          format: int64
        target_ref_id:
          type: string
  responses:
    unauthorisedError:
      description: UnauthorizedError is returned when the request is not authenticated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseBody'
    forbiddenError:
      description: ForbiddenError is returned if the user/token has insufficient permissions to access the requested resource.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseBody'
    recordingRuleWriteTargetResponse:
      description: (empty)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PrometheusRemoteWriteTargetJSON'
    listRecordingRulesResponse:
      description: (empty)
      content:
        application/json:
          schema:
            type: array
            items:
              $ref: '#/components/schemas/RecordingRuleJSON'
    notFoundError:
      description: NotFoundError is returned when the requested resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseBody'
    okResponse:
      description: An OKResponse is returned if the request was successful.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/SuccessResponseBody'
    recordingRuleResponse:
      description: (empty)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RecordingRuleJSON'
    internalServerError:
      description: InternalServerError is a general error indicating something went wrong internally.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseBody'
    unprocessableEntityError:
      description: UnprocessableEntityError
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponseBody'
  securitySchemes:
    api_key:
      type: apiKey
      name: Authorization
      in: header
    basic:
      type: http
      scheme: basic
x-provenance:
  method: harvested
  publisher: Grafana
  source: https://raw.githubusercontent.com/grafana/grafana/main/public/api-merged.json
  note: split by refine-openapis from the provider's own published document, verified by fetch (openapi/_original/*.fetch.json);
    stamped by stamp-openapi-provenance.py (roadmap#793)