https://github.com/radon-h2020/radon-grafana-api-dashboards
This is the API that assigns dashboards specifically to users.The dashboards are protected and proprietary
https://github.com/radon-h2020/radon-grafana-api-dashboards
Last synced: about 2 months ago
JSON representation
This is the API that assigns dashboards specifically to users.The dashboards are protected and proprietary
- Host: GitHub
- URL: https://github.com/radon-h2020/radon-grafana-api-dashboards
- Owner: radon-h2020
- Created: 2020-10-21T09:48:39.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-30T07:17:56.000Z (almost 4 years ago)
- Last Synced: 2025-01-12T11:37:41.419Z (4 months ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# grafana monitoring api> Monitoring repository for the [RADON project](http://radon-h2020.eu)
[](https://opensource.org/licenses/Apache-2.0)[](https://twitter.com/RADON_2020)
Grafana api automates the process of create and delete a grafana dashboard and alerts. There are 3 types of dashboards that supported at that moment
- Container Monitoring Dashboards
-- Monitor cpu, ram, networking of containers
- Custom
-- Monitor the CPU and RAM of serverless functions
- AWS cloudwatch
-- Visualize metrics from AWS Cloudwatch## Preparation
Set up grafana API key.
Set up notification channel

## Installation
### NPM
Use the package manager [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to install dependencies and run the API.```bash
npm i
npm run start
```Set up .env
```
GRAFANA_URL='Grafana server url'
GRAFANA_API_KEY=''
GRAFANA_ADMIN_USERNAME=''
GRAFANA_ADMIN_PASSWORD=''
PORT=""
PROM_DS_NAME='Name_Of_Datasource'
```
If you do not specify port, the API will run at 3100.### Docker
docker build -t grafana_api .
docker run --name graphana_api --env-file env_file -p :3100 grafana_api## Usage
### Alerting
When an insindent occurs grafana_api will send a payload to the given url (payload URL) that contains insident's details .```
{
"jobID": ,
"alertType": ,
"scale":
}
```### Custom Dashboards
**Create Custom dashboard without alert mechanism**```CURL
curl -X POST 'localhost:3100/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"jobid": "jobid",
"type": "custom"
}'```
**Create custom dashboard with alerting**
Send alert to xOPERA (callbackURL) when CPU or RAM surpass a limit. CPU is % and RAM is on MB.
```CURL
curl -X POST 'localhost:3100/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"jobid": "jobid",
"type": "custom",
"cpuAlertThreshold": 50,
"ramAlertThreshold": 900,
"callbackURL": "http://URL"
}'
```
**Create custom dashboard with downscale alert**
Send alert to xOPERA (callbackURL) when CPU or RAM are below the limit
```CURL
curl -X POST 'localhost:3100/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"jobid": "jobid",
"type": "custom",
"cpuDownScaleThreshold": 50,
"ramDownScaleThreshold": 900,
callbackURL": "http://URL"}'
```
**Create custom dashboard with downscale and upscale alert**```CURL
curl -X POST 'localhost:3100/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"jobid": "jobid",
"type": "custom",
"cpuAlertThreshold": 80,
"ramAlertThreshold": 2000,
"cpuDownScaleThreshold": 20,
"ramDownScaleThreshold": 900,
callbackURL": "http://URL"}'
```### Container monitoring dashboard
Create container monitoring dashboard
```CURL
curl -X POST 'localhost:3100/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"jobid": "jobid",
"type": "docker"
}'```
### Create aws cloudwatch monitoring dashboard
```CURL
curl -X POST 'localhost:3100/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"jobid": "jobid",
"type": "awsLambda",
"keys": {
"accessKey": "",
"secretKey": ""
}
}'
```
### Add/Edit Alert into existing APP```CURL
curl -X POST 'localhost:3100/alert' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"jobid": "jobid",
"type": "custom",
"cpuAlertThreshold": 80, #(OPTIONAL)
"ramAlertThreshold": 2000, #(OPTIONAL)
"cpuDownScaleThreshold": 20, #(OPTIONAL)
"ramDownScaleThreshold": 900, #(OPTIONAL)
callbackURL": "http://URL" #(Mandatory if an alert have been setted up)}'
```### Delete Monitoring
```CURL
curl -X DELETE 'localhost:3100/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"jobid": "jobid",
}'
```