Skip to content
Back to skills

2277 Datasources C3a39bb2

ASecurity

Complete reference for Grafana Data Source HTTP API endpoints.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 31, 2026
databasesgobashsqlawsazureapidatabasebackend

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned May 31, 2026

npx -y skills add tools-only/X-Skills --skill 2277-datasources_c3a39bb2 --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 2277 Datasources C3a39bb2?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 2277 Datasources C3a39bb2
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tools-only-2277-datasources-c3a39bb2/badge)](https://www.skillsdirectory.com/skills/tools-only-2277-datasources-c3a39bb2)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Data Sources API Reference

Complete reference for Grafana Data Source HTTP API endpoints.

## Table of Contents

- [List Data Sources](#list-data-sources)
- [Get Data Source](#get-data-source)
- [Create Data Source](#create-data-source)
- [Update Data Source](#update-data-source)
- [Delete Data Source](#delete-data-source)
- [Query Data Source](#query-data-source)
- [Health Check](#health-check)
- [Data Source Resources](#data-source-resources)

---

## List Data Sources

```http
GET /api/datasources
```

**Note:** Default max returned is 5000. Pagination not currently supported.

**Example Response:**

```json
[
  {
    "id": 1,
    "uid": "PE9C8AA5B1A6E7E89",
    "orgId": 1,
    "name": "Prometheus",
    "type": "prometheus",
    "typeName": "Prometheus",
    "typeLogoUrl": "public/app/plugins/datasource/prometheus/img/prometheus_logo.svg",
    "access": "proxy",
    "url": "http://prometheus:9090",
    "user": "",
    "database": "",
    "basicAuth": false,
    "isDefault": true,
    "jsonData": {
      "httpMethod": "POST",
      "manageAlerts": true,
      "prometheusType": "Prometheus"
    },
    "readOnly": false
  }
]
```

---

## Get Data Source

### By ID (Deprecated)

```http
GET /api/datasources/:id
```

### By UID (Recommended)

```http
GET /api/datasources/uid/:uid
```

### By Name

```http
GET /api/datasources/name/:name
```

**Example Response:**

```json
{
  "id": 1,
  "uid": "PE9C8AA5B1A6E7E89",
  "orgId": 1,
  "name": "Prometheus",
  "type": "prometheus",
  "access": "proxy",
  "url": "http://prometheus:9090",
  "basicAuth": false,
  "isDefault": true,
  "jsonData": {
    "httpMethod": "POST",
    "manageAlerts": true
  },
  "secureJsonFields": {},
  "version": 1,
  "readOnly": false
}
```

---

## Create Data Source

```http
POST /api/datasources
```

### Prometheus Example

```json
{
  "name": "Prometheus",
  "type": "prometheus",
  "url": "http://prometheus:9090",
  "access": "proxy",
  "basicAuth": false,
  "isDefault": true,
  "jsonData": {
    "httpMethod": "POST",
    "manageAlerts": true,
    "prometheusType": "Prometheus",
    "prometheusVersion": "2.47.0"
  }
}
```

### InfluxDB Example

```json
{
  "name": "InfluxDB",
  "type": "influxdb",
  "url": "http://influxdb:8086",
  "access": "proxy",
  "basicAuth": false,
  "database": "telegraf",
  "jsonData": {
    "httpMode": "POST",
    "version": "Flux"
  },
  "secureJsonData": {
    "token": "your-influxdb-token"
  }
}
```

### PostgreSQL Example

```json
{
  "name": "PostgreSQL",
  "type": "postgres",
  "url": "postgres:5432",
  "access": "proxy",
  "user": "grafana",
  "database": "grafana",
  "basicAuth": false,
  "jsonData": {
    "sslmode": "disable",
    "maxOpenConns": 100,
    "maxIdleConns": 100,
    "connMaxLifetime": 14400
  },
  "secureJsonData": {
    "password": "your-password"
  }
}
```

### Loki Example

```json
{
  "name": "Loki",
  "type": "loki",
  "url": "http://loki:3100",
  "access": "proxy",
  "basicAuth": false,
  "jsonData": {
    "maxLines": 1000,
    "derivedFields": [
      {
        "matcherRegex": "traceID=(\\w+)",
        "name": "TraceID",
        "url": "${__value.raw}",
        "datasourceUid": "tempo-uid"
      }
    ]
  }
}
```

### CloudWatch Example

```json
{
  "name": "CloudWatch",
  "type": "cloudwatch",
  "access": "proxy",
  "jsonData": {
    "authType": "default",
    "defaultRegion": "us-east-1"
  }
}
```

### Azure Monitor Example

```json
{
  "name": "Azure Monitor",
  "type": "grafana-azure-monitor-datasource",
  "access": "proxy",
  "jsonData": {
    "cloudName": "azuremonitor",
    "tenantId": "your-tenant-id",
    "clientId": "your-client-id",
    "subscriptionId": "your-subscription-id"
  },
  "secureJsonData": {
    "clientSecret": "your-client-secret"
  }
}
```

---

## Update Data Source

### By ID (Deprecated)

```http
PUT /api/datasources/:id
```

### By UID (Recommended)

```http
PUT /api/datasources/uid/:uid
```

**Request Body:** Same as create, include all fields.

---

## Delete Data Source

### By ID (Deprecated)

```http
DELETE /api/datasources/:id
```

### By UID (Recommended)

```http
DELETE /api/datasources/uid/:uid
```

### By Name

```http
DELETE /api/datasources/name/:name
```

---

## Query Data Source

```http
POST /api/ds/query
```

Execute queries against any data source with a backend implementation.

### Prometheus Query Example

```json
{
  "queries": [
    {
      "refId": "A",
      "datasource": {
        "type": "prometheus",
        "uid": "PE9C8AA5B1A6E7E89"
      },
      "expr": "up{job=\"prometheus\"}",
      "instant": false,
      "range": true,
      "intervalMs": 15000,
      "maxDataPoints": 1000
    }
  ],
  "from": "now-1h",
  "to": "now"
}
```

### Loki Query Example

```json
{
  "queries": [
    {
      "refId": "A",
      "datasource": {
        "type": "loki",
        "uid": "loki-uid"
      },
      "expr": "{job=\"nginx\"} |= \"error\"",
      "queryType": "range",
      "maxLines": 1000
    }
  ],
  "from": "now-1h",
  "to": "now"
}
```

### SQL Query Example

```json
{
  "queries": [
    {
      "refId": "A",
      "datasource": {
        "type": "postgres",
        "uid": "postgres-uid"
      },
      "rawSql": "SELECT time, value FROM metrics WHERE $__timeFilter(time)",
      "format": "time_series"
    }
  ],
  "from": "now-1h",
  "to": "now"
}
```

**Response Structure:**

```json
{
  "results": {
    "A": {
      "frames": [
        {
          "schema": {
            "refId": "A",
            "fields": [
              {"name": "time", "type": "time"},
              {"name": "value", "type": "number"}
            ]
          },
          "data": {
            "values": [
              [1644488152084, 1644488212084],
              [0.95, 0.97]
            ]
          }
        }
      ]
    }
  }
}
```

---

## Health Check

```http
GET /api/datasources/uid/:uid/health
```

**Example Response (Success):**

```json
{
  "status": "OK",
  "message": "Successfully connected to Prometheus"
}
```

**Example Response (Error):**

```json
{
  "status": "ERROR",
  "message": "Post \"http://prometheus:9090/api/v1/query\": dial tcp: connection refused"
}
```

---

## Data Source Resources

Access data source-specific resources (metrics, dimensions, etc.).

```http
GET /api/datasources/uid/:uid/resources/:resource
```

### CloudWatch Dimension Keys Example

```bash
GET /api/datasources/uid/cloudwatch-uid/resources/dimension-keys?region=us-east-1&namespace=AWS/EC2
```

### Prometheus Label Values Example

```bash
GET /api/datasources/uid/prometheus-uid/resources/api/v1/label/__name__/values
```

---

## Common Data Source Types

| Type | Plugin ID |
|------|-----------|
| Prometheus | `prometheus` |
| Loki | `loki` |
| InfluxDB | `influxdb` |
| PostgreSQL | `postgres` |
| MySQL | `mysql` |
| Elasticsearch | `elasticsearch` |
| CloudWatch | `cloudwatch` |
| Azure Monitor | `grafana-azure-monitor-datasource` |
| Google Cloud Monitoring | `stackdriver` |
| Graphite | `graphite` |
| Tempo | `tempo` |
| Jaeger | `jaeger` |
| Zipkin | `zipkin` |

Files in this skill

  • README.md905 B
  • skill.md6.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.