

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Peringatan Saluran Pemberitahuan API
<a name="v12-Grafana-API-AlertingNotificationChannels"></a>

Gunakan API Saluran Pemberitahuan Peringatan untuk membuat, memperbarui, menghapus, dan mengambil saluran notifikasi.

Identifier (id) dari saluran notifikasi adalah nilai numerik auto-incrementing dan hanya unik per ruang kerja. Pengenal unik (uid) dari saluran notifikasi dapat digunakan untuk mengidentifikasi folder di antara beberapa ruang kerja secara unik. Ini dibuat secara otomatis jika Anda tidak menyediakannya saat Anda membuat saluran notifikasi. Uid memungkinkan memiliki URL yang konsisten untuk mengakses saluran notifikasi dan saat menyinkronkan saluran notifikasi antara beberapa ruang kerja Grafana yang Dikelola Amazon. 

**catatan**  
Untuk menggunakan API Grafana dengan ruang kerja Grafana yang Dikelola Amazon, Anda harus memiliki token akun layanan yang valid. Anda menyertakan ini di `Authorization` bidang dalam permintaan API.

## Dapatkan semua saluran notifikasi
<a name="v12-Grafana-API-AlertNotificationChannels-getall"></a>

Mengembalikan semua saluran notifikasi bahwa pengguna yang diautentikasi memiliki izin untuk melihat.

```
GET /api/alert-notifications
```

**Contoh permintaan**

```
GET /api/alert-notifications HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

[
  {
    "id": 1,
    "uid": "sns-uid",
    "name": "test",
    "type": "sns",
    "isDefault": false,
    "sendReminder": false,
    "disableResolveMessage": false,
    "frequency": "",
    "created": "2023-09-08T19:57:56Z",
    "updated": "2023-09-08T19:57:56Z",
    "settings": {
      "authProvider": "default",
      "autoResolve": true,
      "httpMethod": "POST",
      "messageFormat": "json",
      "severity": "critical",
      "topic": "<SNS-TOPIC-ARN>",
      "uploadImage": false
    },
    "secureFields": {}
  }
]
```

## Dapatkan semua saluran notifikasi (pencarian)
<a name="v12-Grafana-API-AlertNotificationChannels-getlookup"></a>

Mengembalikan semua saluran notifikasi, tetapi dengan informasi yang kurang rinci. Dapat diakses oleh pengguna yang diautentikasi dan terutama digunakan untuk menyediakan saluran notifikasi peringatan di UI konsol ruang kerja Grafana saat mengonfigurasi aturan peringatan.

```
GET /api/alert-notifications/lookup
```

**Contoh permintaan**

```
GET /api/alert-notifications/lookup HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

[
  {
    "id": 1,
    "uid": "sns-uid",
    "name": "test",
    "type": "sns",
    "isDefault": false
  },
  {
    "id": 2,
    "uid": "slack-uid",
    "name": "Slack",
    "type": "slack",
    "isDefault": false
  }
]
```

## Dapatkan semua saluran notifikasi melalui UID
<a name="v12-Grafana-API-AlertNotificationChannels-getbyUID"></a>

```
GET /api/alert-notifications/uid/:uid
```

**Contoh permintaan**

```
GET /api/alert-notifications/uid/sns-uid HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

{
  "id": 1,
  "uid": "sns-uid",
  "name": "test",
  "type": "sns",
  "isDefault": false,
  "sendReminder": false,
  "disableResolveMessage": false,
  "frequency": "",
  "created": "2023-09-08T19:57:56Z",
  "updated": "2023-09-08T19:57:56Z",
  "settings": {
    "authProvider": "default",
    "autoResolve": true,
    "httpMethod": "POST",
    "messageFormat": "json",
    "severity": "critical",
    "topic": "<SNS-TOPIC-ARN>",
    "uploadImage": false
  },
  "secureFields": {}
}
```

## Dapatkan semua saluran notifikasi berdasarkan Id
<a name="v12-Grafana-API-AlertNotificationChannels-getbyId"></a>

```
GET /api/alert-notifications/:id
```

**Contoh permintaan**

```
GET /api/alert-notifications/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

{
  "id": 1,
  "uid": "sns-uid",
  "name": "test",
  "type": "sns",
  "isDefault": false,
  "sendReminder": false,
  "disableResolveMessage": false,
  "frequency": "",
  "created": "2023-09-08T19:57:56Z",
  "updated": "2023-09-08T19:57:56Z",
  "settings": {
    "authProvider": "default",
    "autoResolve": true,
    "httpMethod": "POST",
    "messageFormat": "json",
    "severity": "critical",
    "topic": "<SNS-TOPIC-ARN>",
    "uploadImage": false
  },
  "secureFields": {}
}
```

## Buat saluran notifikasi
<a name="v12-Grafana-API-AlertNotificationChannels-Create"></a>

Untuk melihat saluran notifikasi apa yang didukung oleh Grafana Terkelola Amazon, lihat daftar notifier yang didukung di. [Bekerja dengan titik kontak](alert-contact-points.md)

Di Grafana versi 12, gunakan Alerting Provisioning API untuk membuat titik kontak. `/api/alert-notifications`Titik akhir warisan tidak lagi tersedia.

**Contoh permintaan**

```
POST /api/v1/provisioning/contact-points HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890

{
  "uid": "new-sns-uid",
  "name": "sns alert notification",
  "type": "sns",
  "isDefault": false,
  "sendReminder": false,
  "settings": {
    "topic_arn": "<SNS-TOPIC-ARN>",
    "subject": "<SUBJECT>"
  }
}
```

## Perbarui saluran notifikasi dengan UID
<a name="v12-Grafana-API-AlertNotificationChannels-UpdatebyUID"></a>

```
PUT /api/alert-notifications/uid/:uid
```

**Contoh permintaan**

```
PUT /api/alert-notifications/uid/sns-uid HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890

{
  "uid": "sns-uid", // optional
  "name": "sns alert notification",  //Required
  "type":  "sns", //Required
  "isDefault": false,
  "sendReminder": true,
  "frequency": "15m",
  "settings": {
    "authProvider": "default",
    "autoResolve": true,
    "httpMethod": "POST",
    "messageFormat": "json",
    "severity": "critical",
    "topic": "<SNS-TOPIC-ARN>",
    "uploadImage": false
  }
}
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

{
  "id": 1,
  "uid": "sns-uid",
  "name": "sns alert notification",
  "type": "sns",
  "isDefault": false,
  "sendReminder": true,
  "frequency": "15m",
  "settings": {
    "authProvider": "default",
    "autoResolve": true,
    "httpMethod": "POST",
    "messageFormat": "json",
    "severity": "critical",
    "topic": "<SNS-TOPIC-ARN>",
    "uploadImage": false
  },
  "created": "2017-01-01 12:34",
  "updated": "2017-01-01 12:34"
}
```

## Perbarui saluran notifikasi berdasarkan Id
<a name="v12-Grafana-API-AlertNotificationChannels-UpdatebyId"></a>

```
PUT /api/alert-notifications/:id
```

**Contoh permintaan**

```
PUT /api/alert-notifications/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890

{
  "id": 1,
  "uid": "sns-uid", // optional
  "name": "sns alert notification",  //Required
  "type":  "sns", //Required
  "isDefault": false,
  "sendReminder": true,
  "frequency": "15m",
  "settings": {
    "authProvider": "default",
    "autoResolve": true,
    "httpMethod": "POST",
    "messageFormat": "json",
    "severity": "critical",
    "topic": "<SNS-TOPIC-ARN>",
    "uploadImage": false
  }
}
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

{
  "id": 1,
  "uid": "sns-uid",
  "name": "sns alert notification",
  "type": "sns",
  "isDefault": false,
  "sendReminder": true,
  "frequency": "15m",
  "settings": {
    "authProvider": "default",
    "autoResolve": true,
    "httpMethod": "POST",
    "messageFormat": "json",
    "severity": "critical",
    "topic": "<SNS-TOPIC-ARN>",
    "uploadImage": false
  },
  "created": "2017-01-01 12:34",
  "updated": "2017-01-01 12:34"
}
```

## Hapus saluran notifikasi oleh UID
<a name="v12-Grafana-API-AlertNotificationChannels-DeletebyUID"></a>

```
DELETE /api/alert-notifications/uid/:uid
```

**Contoh permintaan**

```
DELETE /api/alert-notifications/uid/sns-uid HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

{
  "message": "Notification deleted"
}
```

## Hapus saluran notifikasi oleh Id
<a name="v12-Grafana-API-AlertNotificationChannels-DeletebyId"></a>

```
DELETE /api/alert-notifications/:id
```

**Contoh permintaan**

```
DELETE /api/alert-notifications/1 HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

{
  "message": "Notification deleted"
}
```

## Uji saluran notifikasi
<a name="v12-Grafana-API-AlertNotificationChannels-Test"></a>

Mengirim pesan notifikasi pengujian untuk jenis dan pengaturan saluran notifikasi yang diberikan.

```
POST /api/alert-notifications/test
```

**Contoh permintaan**

```
POST /api/alert-notifications/test HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer 1234abcd567exampleToken890

{
  "type":  "sns",
  "settings": {
    "authProvider": "default",
    "autoResolve": true,
    "httpMethod": "POST",
    "messageFormat": "json",
    "severity": "critical",
    "topic": "<SNS-TOPIC-ARN>",
    "uploadImage": false
  }
}
```

**Contoh respon**

```
HTTP/1.1 200
Content-Type: application/json

{
  "message": "Test notification sent"
}
```