Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Combine multiple JSON parameters to one argument? #601

Open
NekoYos opened this issue Aug 30, 2022 · 0 comments
Open

Combine multiple JSON parameters to one argument? #601

NekoYos opened this issue Aug 30, 2022 · 0 comments

Comments

@NekoYos
Copy link

NekoYos commented Aug 30, 2022

How to combine multiple JSON parameters to one argument?

I'm sent POST JSON data from prometheus with this structure:

{
  "version": "4",
  "groupKey": [<string>](https://prometheus.io/docs/alerting/latest/configuration/#string),              // key identifying the group of alerts (e.g. to deduplicate)
  "truncatedAlerts": [<int>](https://prometheus.io/docs/alerting/latest/configuration/#int),          // how many alerts have been truncated due to "max_alerts"
  "status": "<resolved|firing>",
  "receiver": [<string>](https://prometheus.io/docs/alerting/latest/configuration/#string),
  "groupLabels": <object>,
  "commonLabels": <object>,
  "commonAnnotations": <object>,
  "externalURL": [<string>](https://prometheus.io/docs/alerting/latest/configuration/#string),           // backlink to the Alertmanager.
  "alerts": [
    {
      "status": "<resolved|firing>",
      "labels": <object>,
      "annotations": <object>,
      "startsAt": "<rfc3339>",
      "endsAt": "<rfc3339>",
      "generatorURL": [<string>](https://prometheus.io/docs/alerting/latest/configuration/#string),      // identifies the entity that caused the alert
      "fingerprint": [<string>](https://prometheus.io/docs/alerting/latest/configuration/#string)        // fingerprint to identify the alert
    },
    ...
  ]
}

Parse payload to script args:

  pass-arguments-to-command:
  - source: url
    name: url
  - source: url
    name: room
  - source: url
    name: token
  - source: payload
    name: alerts.0.annotations.summary

We need combine all parameters from:
alerts.0.annotations.summary
alerts.1.annotations.summary
alerts.2.annotations.summary
alerts.last.annotations.summary
to one args

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants