Google cloud platform 有人能在Google Stackdriver JSON警报消息(通过webhook发送给alerta)中提供密钥定义吗?

Google cloud platform 有人能在Google Stackdriver JSON警报消息(通过webhook发送给alerta)中提供密钥定义吗?,google-cloud-platform,alert,message,stackdriver,google-cloud-stackdriver,Google Cloud Platform,Alert,Message,Stackdriver,Google Cloud Stackdriver,我们需要一种可靠的方法从stackdriver警报消息(发送到alerta webhook)中获取受监控资源的gcp项目id(而不是stackdriver项目id) 我找到的一个可能的关键可能是: "rawData": { "incident": { "resource_name": "squad-spielwiese test-ezander", } } 我希望对密钥资源名称的语法(看起来像资源的项目名称resource name)或者是否有更好的选项适合我的情况下是

我们需要一种可靠的方法从stackdriver警报消息(发送到alerta webhook)中获取受监控资源的gcp项目id(而不是stackdriver项目id)

我找到的一个可能的关键可能是:

"rawData": {
    "incident": {
      "resource_name": "squad-spielwiese test-ezander",
}   }
我希望对密钥资源名称的语法(看起来像
资源的项目名称resource name
)或者是否有更好的选项适合我的情况下是100%安全的,所以我尝试查找有关stackdriver警报消息密钥的任何文档,但没有成功

我不敢相信,没有人记录下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": "--"
}
{
“属性”:{
“incidentId”:“0.lbon2fb3ylfn”,
“ip”:“66.249.87.155”,
“isOutOfHours”:错误,
“moreInfo”:“,
“资源ID”:“,
“runBookUrl”:http://www.example.com/wiki/RunBook/GCE-VM-Instance---CPU-utilization-for-4427379606643423981"
},
“关联”:[],
“createTime”:“2019-08-29T12:25:54.000Z”,
“客户”:空,
“重复计数”:0,
“环境”:“生产”,
“事件”:“GCE VM实例-4427379606643423981的CPU利用率”,
“组”:“云”,
“历史”:[
{
“事件”:“GCE VM实例-4427379606643423981的CPU利用率”,
“href”:”https://127.0.0.1:9090/alerta-dev/api/alert/c5ae3e1c-53ad-42a3-b053-3321b3e96123“,
“id”:“c5ae3e1c-53ad-42a3-b053-3321b3e96123”,
“严重性”:“正常”,
“状态”:空,
“text:“确定:具有度量标签{instance_name=test ezander}的squad spielwiese test ezander的CPU利用率恢复正常,值为0.001。”,
“类型”:“严重性”,
“更新时间”:“2019-08-29T12:25:50.000Z”,
“值”:--”
},
{
“事件”:“GCE VM实例-4427379606643423981的CPU利用率”,
“href”:”https://127.0.0.1:9090/alerta-dev/api/alert/c5ae3e1c-53ad-42a3-b053-3321b3e96123“,
“id”:“c5ae3e1c-53ad-42a3-b053-3321b3e96123”,
“严重性”:空,
“状态”:“已关闭”,
“文本”:“新警报状态更改”,
“类型”:“状态”,
“更新时间”:“2019-08-29T12:25:50.000Z”,
“值”:空
},
{
“事件”:“GCE VM实例-4427379606643423981的CPU利用率”,
“href”:”https://127.0.0.1:9090/alerta-dev/api/alert/312fa29e-7c76-4e24-85f7-f3ecd09cc2f6“,
“id”:“312fa29e-7c76-4e24-85f7-f3ecd09cc2f6”,
“严重性”:“严重性”,
“状态”:空,
“文本”:“严重:具有度量标签{instance_name=test ezander}的squad spielwiese test ezander的CPU利用率高于阈值0.2,值为1.000。”,
“类型”:“严重性”,
“更新时间”:“2019-08-29T12:25:54.000Z”,
“值”:--”
},
{
“事件”:“GCE VM实例-4427379606643423981的CPU利用率”,
“href”:”https://127.0.0.1:9090/alerta-dev/api/alert/312fa29e-7c76-4e24-85f7-f3ecd09cc2f6“,
“id”:“312fa29e-7c76-4e24-85f7-f3ecd09cc2f6”,
“严重性”:空,
“状态”:“打开”,
“文本”:“相关警报状态更改”,
“类型”:“状态”,
“更新时间”:“2019-08-29T12:25:54.000Z”,
“值”:空
}
],
“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”,
“来源”:“Stackdriver”,
“以前的严重性”:“确定”,
“原始数据”:{
“事件”:{
“条件名称”:“GCE虚拟机实例-4427379606643423981的CPU利用率”,
“文件”:{
“内容”:“BLA”,
“mime_类型”:“文本/标记”
},
“结束于”:null,
“事件id”:“0.lbon2fb3ylfn”,
“政策名称”:“ez政策”,
“资源”:{
“标签”:{
“实例id”:“3269982608675192580”,
“区域”:“europe-west3-c”
},
“类型”:“gce_实例”
},
“资源id”:“,
“资源名称”:“小队斯皮尔维塞测试埃赞德”,
“起始时间”:1567081554,
“状态”:“打开”,
“摘要”:“具有度量标签{instance_name=test ezander}的squad spielwiese test ezander的CPU利用率高于阈值0.2,值为1.000。”,
“url”:”https://app.google.stackdriver.com/incidents/0.lbon2fb3ylfn?project=squad-斯皮尔维塞“
},
“版本”:“1.2”
},
“接收时间”:“2019-08-29T12:29:50.947Z”,
“重复”:错误,
“资源”:“斯皮尔维尔小队测试埃赞德”,
“服务”:[
“ez政策”
],
“严重性”:“严重性”,
“状态”:“打开”,
“标签”:[],
“文本”:“严重:具有度量标签{instance_name=test ezander}的squad spielwiese test ezander的CPU利用率高于阈值0.2,值为1.000。”,
“超时”:86400,
“趋势指示”:“更严重”,
“类型”:“StackDriverAllert”,
“值”:--”
}

没有关于每个stackdriver响应键的正式文档,但是在您的示例中,您可以通过仔细阅读响应字符串来识别VM实例和项目ID

e、 g.(“资源”:“squad spielwiese test ezander”),其中“squad spielwiese”代表您的项目ID,“test ezander”代表您的VM实例名称。 此外,您还可以查看URL键,它将始终显示您的项目ID:“URL”:“斯皮尔维塞队”


在stackdriver中,由于“安全”原因,没有一种自然的方法可以仅使用项目id检索键值,但是。。您可以使用API方法绕过调用,并将其实现到代码中

没有关于每个stackdriver响应键的正式文档,但是在您的示例中,您可以通过仔细阅读响应字符串来识别VM实例和项目ID

e、 g.(“资源”:“小队斯皮尔维塞测试埃赞德”)当