有人可以在 Google Stackdriver JSON 警报消息(通过 webhook 发送到 alerta)中提供键的定义吗?
Can someone provide definition of keys in Google Stackdriver JSON alert message (sent via webhook to alerta)?
我们需要一种可靠的方法来从 stackdriver 警报消息(发送到 alerta webhook)中获取受监控资源的 gcp 项目 ID(不是 stackdriver 项目 id)。
我找到的一个可能的密钥可能是:
"rawData": {
"incident": {
"resource_name": "squad-spielwiese test-ezander",
} }
我想 100% 安全地了解键 resource_name 的语法(看起来像 resource's project name <blanc> resource name
),或者如果我的情况有更好的选择,所以我试图找到有关 stackdriver alert 的任何文档消息键 - 没有成功。
我不敢相信没有人记录了 stackdriver webhook 警报消息中单个键代表什么的确切定义。有人可以帮我找到更详细的信息吗?
这是 alerta 中的完整示例:
{
"attributes": {
"incidentId": "0.lbon2fb3ylfn",
"ip": "66.249.87.155",
"isOutOfHours": false,
"moreInfo": "<a href=\"https://app.google.stackdriver.com/incidents/0.lbon2fb3ylfn?project=squad-spielwiese\" target=\"_blank\">Stackdriver Console</a>",
"resourceId": "",
"runBookUrl": "http://www.example.com/wiki/RunBook/GCE-VM-Instance---CPU-utilization-for-4427379606643423981"
},
"correlate": [],
"createTime": "2019-08-29T12:25:54.000Z",
"customer": null,
"duplicateCount": 0,
"environment": "Production",
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"group": "Cloud",
"history": [
{
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"id": "c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"severity": "ok",
"status": null,
"text": "OK: CPU utilization for squad-spielwiese test-ezander with metric labels {instance_name=test-ezander} returned to normal with a value of 0.001.",
"type": "severity",
"updateTime": "2019-08-29T12:25:50.000Z",
"value": "--"
},
{
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"id": "c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"severity": null,
"status": "closed",
"text": "new alert status change",
"type": "status",
"updateTime": "2019-08-29T12:25:50.000Z",
"value": null
},
{
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"id": "312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"severity": "critical",
"status": null,
"text": "CRITICAL: CPU utilization for squad-spielwiese test-ezander with metric labels {instance_name=test-ezander} is above the threshold of 0.2 with a value of 1.000.",
"type": "severity",
"updateTime": "2019-08-29T12:25:54.000Z",
"value": "--"
},
{
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"id": "312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"severity": null,
"status": "open",
"text": "correlated alert status change",
"type": "status",
"updateTime": "2019-08-29T12:25:54.000Z",
"value": null
}
],
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"id": "c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"lastReceiveId": "312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"lastReceiveTime": "2019-08-29T12:29:50.947Z",
"origin": "Stackdriver",
"previousSeverity": "ok",
"rawData": {
"incident": {
"condition_name": "GCE VM Instance - CPU utilization for 4427379606643423981",
"documentation": {
"content": "BLA ",
"mime_type": "text/markdown"
},
"ended_at": null,
"incident_id": "0.lbon2fb3ylfn",
"policy_name": "ez-policy",
"resource": {
"labels": {
"instance_id": "3269982608675192580",
"zone": "europe-west3-c"
},
"type": "gce_instance"
},
"resource_id": "",
"resource_name": "squad-spielwiese test-ezander",
"started_at": 1567081554,
"state": "open",
"summary": "CPU utilization for squad-spielwiese test-ezander with metric labels {instance_name=test-ezander} is above the threshold of 0.2 with a value of 1.000.",
"url": "https://app.google.stackdriver.com/incidents/0.lbon2fb3ylfn?project=squad-spielwiese"
},
"version": "1.2"
},
"receiveTime": "2019-08-29T12:29:50.947Z",
"repeat": false,
"resource": "squad-spielwiese test-ezander",
"service": [
"ez-policy"
],
"severity": "critical",
"status": "open",
"tags": [],
"text": "CRITICAL: CPU utilization for squad-spielwiese test-ezander with metric labels {instance_name=test-ezander} is above the threshold of 0.2 with a value of 1.000.",
"timeout": 86400,
"trendIndication": "moreSevere",
"type": "stackdriverAlert",
"value": "--"
}
没有关于每个 stackdriver 响应键是什么的官方文档,但在您的示例中,您可以通过仔细阅读响应字符串来识别 VM 实例和项目 ID。
例如("resource": "squad-spielwiese test-ezander") 其中 "squad-spielwiese" 代表您的项目 ID,"test-ezander" 代表您的 VM 实例名称。
您还可以查看 URL 键,它始终会显示您的项目 ID:"url": "https://app.google.stackdriver.com/incidents/0.lbon2fb3ylfn?project=squad-spielwiese"。 =12=]
在 stackdriver 中,由于 "secure" 原因,没有自然的方法可以仅使用项目 ID 检索键值,但是..您可以使用 this API 方法解决调用并将其实现到您的代码中。
我们需要一种可靠的方法来从 stackdriver 警报消息(发送到 alerta webhook)中获取受监控资源的 gcp 项目 ID(不是 stackdriver 项目 id)。
我找到的一个可能的密钥可能是:
"rawData": {
"incident": {
"resource_name": "squad-spielwiese test-ezander",
} }
我想 100% 安全地了解键 resource_name 的语法(看起来像 resource's project name <blanc> resource name
),或者如果我的情况有更好的选择,所以我试图找到有关 stackdriver alert 的任何文档消息键 - 没有成功。
我不敢相信没有人记录了 stackdriver webhook 警报消息中单个键代表什么的确切定义。有人可以帮我找到更详细的信息吗?
这是 alerta 中的完整示例:
{
"attributes": {
"incidentId": "0.lbon2fb3ylfn",
"ip": "66.249.87.155",
"isOutOfHours": false,
"moreInfo": "<a href=\"https://app.google.stackdriver.com/incidents/0.lbon2fb3ylfn?project=squad-spielwiese\" target=\"_blank\">Stackdriver Console</a>",
"resourceId": "",
"runBookUrl": "http://www.example.com/wiki/RunBook/GCE-VM-Instance---CPU-utilization-for-4427379606643423981"
},
"correlate": [],
"createTime": "2019-08-29T12:25:54.000Z",
"customer": null,
"duplicateCount": 0,
"environment": "Production",
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"group": "Cloud",
"history": [
{
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"id": "c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"severity": "ok",
"status": null,
"text": "OK: CPU utilization for squad-spielwiese test-ezander with metric labels {instance_name=test-ezander} returned to normal with a value of 0.001.",
"type": "severity",
"updateTime": "2019-08-29T12:25:50.000Z",
"value": "--"
},
{
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"id": "c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"severity": null,
"status": "closed",
"text": "new alert status change",
"type": "status",
"updateTime": "2019-08-29T12:25:50.000Z",
"value": null
},
{
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"id": "312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"severity": "critical",
"status": null,
"text": "CRITICAL: CPU utilization for squad-spielwiese test-ezander with metric labels {instance_name=test-ezander} is above the threshold of 0.2 with a value of 1.000.",
"type": "severity",
"updateTime": "2019-08-29T12:25:54.000Z",
"value": "--"
},
{
"event": "GCE VM Instance - CPU utilization for 4427379606643423981",
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"id": "312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"severity": null,
"status": "open",
"text": "correlated alert status change",
"type": "status",
"updateTime": "2019-08-29T12:25:54.000Z",
"value": null
}
],
"href": "https://127.0.0.1:9090/alerta-dev/api/alert/c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"id": "c5ae3e1c-53ad-42a3-b053-3321b3e96123",
"lastReceiveId": "312fa29e-7c76-4e24-85f7-f3ecd09cc2f6",
"lastReceiveTime": "2019-08-29T12:29:50.947Z",
"origin": "Stackdriver",
"previousSeverity": "ok",
"rawData": {
"incident": {
"condition_name": "GCE VM Instance - CPU utilization for 4427379606643423981",
"documentation": {
"content": "BLA ",
"mime_type": "text/markdown"
},
"ended_at": null,
"incident_id": "0.lbon2fb3ylfn",
"policy_name": "ez-policy",
"resource": {
"labels": {
"instance_id": "3269982608675192580",
"zone": "europe-west3-c"
},
"type": "gce_instance"
},
"resource_id": "",
"resource_name": "squad-spielwiese test-ezander",
"started_at": 1567081554,
"state": "open",
"summary": "CPU utilization for squad-spielwiese test-ezander with metric labels {instance_name=test-ezander} is above the threshold of 0.2 with a value of 1.000.",
"url": "https://app.google.stackdriver.com/incidents/0.lbon2fb3ylfn?project=squad-spielwiese"
},
"version": "1.2"
},
"receiveTime": "2019-08-29T12:29:50.947Z",
"repeat": false,
"resource": "squad-spielwiese test-ezander",
"service": [
"ez-policy"
],
"severity": "critical",
"status": "open",
"tags": [],
"text": "CRITICAL: CPU utilization for squad-spielwiese test-ezander with metric labels {instance_name=test-ezander} is above the threshold of 0.2 with a value of 1.000.",
"timeout": 86400,
"trendIndication": "moreSevere",
"type": "stackdriverAlert",
"value": "--"
}
没有关于每个 stackdriver 响应键是什么的官方文档,但在您的示例中,您可以通过仔细阅读响应字符串来识别 VM 实例和项目 ID。
例如("resource": "squad-spielwiese test-ezander") 其中 "squad-spielwiese" 代表您的项目 ID,"test-ezander" 代表您的 VM 实例名称。 您还可以查看 URL 键,它始终会显示您的项目 ID:"url": "https://app.google.stackdriver.com/incidents/0.lbon2fb3ylfn?project=squad-spielwiese"。 =12=]
在 stackdriver 中,由于 "secure" 原因,没有自然的方法可以仅使用项目 ID 检索键值,但是..您可以使用 this API 方法解决调用并将其实现到您的代码中。