Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Create Alerts (Checks, Notification Endpoint, Notification Rule) via influxdb-client-go in Influxdb2 #385

Open
yockgen opened this issue Sep 11, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@yockgen
Copy link

yockgen commented Sep 11, 2023

Specifications

  • Client Version: github.com/influxdata/influxdb-client-go/v2 v2.12.3
  • InfluxDB Version: InfluxDB v2.3.0+SNAPSHOT.090f681737
  • Platform: Linux

Steps to reproduce

Is it any way to create Alerts (Checks, Notification Endpoint, Notification Rule) via influxdb-client-go in Influxdb2?

Expected behavior

influxdb-client-go/v2 allowed Alerts to be create via Library

Actual behavior

influxdb-client-go/v2 not allowed Alerts to be create via Library

Additional info

No response

@yockgen yockgen added the bug Something isn't working label Sep 11, 2023
@powersj
Copy link
Contributor

powersj commented Sep 12, 2023

hi @yockgen,

Can you point to the API endpoint for alerts you are trying to use? There is support for creating tasks.

@yockgen
Copy link
Author

yockgen commented Sep 13, 2023

hi @yockgen,

Can you point to the API endpoint for alerts you are trying to use? There is support for creating tasks.

Hi @powersj,
Thanks for the info! I'm trying to find information on how to use "influx-client-go" to do something like below (to create CHECKS/Endpoint/Rules for Alert):

curl -X POST "http://10.49.76.106:32701/api/v2/checks" \
-H "Authorization: Token  xxxxxxx" \
-H "Content-Type: application/json" \
-d '{
  "name": "Testing 01",
  "type": "threshold",  
  "query": {
    "text": "from(bucket: \"intel\")\n  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n  |> filter(fn: (r) => r[\"_measurement\"] == \"mem_available_percent\")\n  |> filter(fn: (r) => r[\"_field\"] == \"gauge\")\n  |> filter(fn: (r) => r[\"host\"] == \"node01\")\n  |> aggregateWindow(every: 1m, fn: last, createEmpty: false)\n  |> yield(name: \"last\")",
    "editMode": "builder",
    "name": "",
    "builderConfig": {
      "buckets": ["company"],
      "tags": [
        {
          "key": "_measurement",
          "values": ["mem_available_percent"],
          "aggregateFunctionType": "filter"
        },
        {
          "key": "_field",
          "values": ["gauge"],
          "aggregateFunctionType": "filter"
        },
        {
          "key": "host",
          "values": ["3214261f-3ee2-1169-841c-1c697aa4038c"],
          "aggregateFunctionType": "filter"
        }
      ],
      "functions": [
        {
          "name": "last"
        }
      ],
      "aggregateWindow": {
        "period": "1m",
        "fillValues": false
      }
    }
  },
  "every": "5m",
  "offset": "30s",  
  "status": "active",
  "description": "My check description",
  "labels": ["label1", "label2"],
  "message": "Check triggered",
  "orgID": "xxxxxxx"
}'

Thanks of your guidance!

@powersj
Copy link
Contributor

powersj commented Sep 13, 2023

@bednar does this library expose anything for the /api/v2/checks endpoint? Quick search doesn't seem to show it.

@vlastahajek vlastahajek added enhancement New feature or request and removed bug Something isn't working labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants