Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Create a folder from the Grafana GUI or execute this command :
python3 scripts/grafana_create_folder.py {{FOLDER_NAME}}
```

This command should return a json with a field "uid" which will be {{FOLDER_UID}} for the next command
This command should return an "uid" which will be {{FOLDER_UID}} for the next command

Then we can create dashboards in the previously created folder.

Expand All @@ -98,7 +98,9 @@ curl localhost:7000/api/dashboards/uid/{{DASHBOARD_UID}} > new_dashboard.json
Edit "new_dashboard.json" file, then :
- replace "uid" value by a new value corresponding to a UUID (you can use https://www.uuidgenerator.net/)
- remove all those properties :
- "id"
- the root "id" (you can set it to null)
- "meta"
- "dashboard" (the content of the "dashboard" field will become the whole JSON)

*Note: check **resources/grafana/dashboards/users-metrics.json** for a working template file*

Expand All @@ -112,7 +114,7 @@ Create a folder from the Grafana GUI or execute this command :
python3 scripts/grafana_create_folder.py {{FOLDER_NAME}}
```

This command should return a json with a field "uid" which will be {{FOLDER_UID}} for the next command
This command should return an "uid" which will be {{FOLDER_UID}} for the next command

Then we can create alert-rules in the previously created folder.

Expand Down
5 changes: 3 additions & 2 deletions scripts/functions/grafana/folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ def __create_folder(json_data):
print("Create folder : %s" % json_data['title'])
result = requests.post(GRAFANA_FOLDERS_URL, json=json_data, headers=constant.GRAFANA_HEADERS, cookies=constant.GRAFANA_COOKIES)
result.raise_for_status()
print("Folder successfully (re)created : %s" % json_data['title'])
return result.json()['uid']
folder_uid = result.json()['uid']
print("Folder successfully (re)created with uid : %s" % folder_uid)
return folder_uid
except RequestException as e:
if result.status_code == requests.codes.conflict:
print("Folder already exist : %s" % json_data['title'])
Expand Down
2 changes: 1 addition & 1 deletion scripts/grafana_create_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# @author Kevin Le Saulnier <kevin.lesaulnier at rte-france.com>
# @author Slimane Amar <slimane.amar at rte-france.com>
#
GRAFANA_ALERTS_DIR = 'resources/grafana/alerts/'
GRAFANA_ALERTS_DIR = 'scripts/resources/grafana/alerts/'
GRAFANA_LOGS_ALERTS_DIR = GRAFANA_ALERTS_DIR + 'logs'
GRAFANA_METRICS_ALERTS_DIR = GRAFANA_ALERTS_DIR + 'metrics'

Expand Down
2 changes: 1 addition & 1 deletion scripts/grafana_create_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#
# @author Slimane Amar <slimane.amar at rte-france.com>
#
GRAFANA_DASHBOARDS_DIR = 'resources/grafana/dashboards'
GRAFANA_DASHBOARDS_DIR = 'scripts/resources/grafana/dashboards'

parser = argparse.ArgumentParser(description='Send requests to the grafana to create or update dashboards into one folder')
group = parser.add_mutually_exclusive_group(required=True)
Expand Down
Loading
Loading