Skip to content

Commit

Permalink
Merge pull request #12 from unfor19/fix/11
Browse files Browse the repository at this point in the history
Fix/11
  • Loading branch information
unfor19 committed Jan 12, 2021
2 parents 7f9e860 + 49bcbbb commit 74045c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Install minikube
uses: opsgang/ga-setup-minikube@v0.1.1
uses: unfor19/ga-setup-minikube@ca5bb1bd1ae316f95a86f882b9eb9ae866b8ab9e
with:
minikube-version: 1.7.2
k8s-version: 1.17.2
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ $ pip install frigga
### Getting Started

1. git clone this repository
1. Run Docker daemon (Docker for Desktop)
1. Make sure port 8080 is not in use
1. Deploy locally the services: Prometheus, Grafana, node-exporter and cadvisor

```bash
Expand All @@ -138,6 +140,7 @@ $ pip install frigga
1. Get all the metrics that are used in your Grafana dasboards

```bash
$ export GRAFANA_API_KEY=the-key-that-was-generated-in-the-deploy-locally-step
$ frigga gl -gurl http://localhost:3000 -gkey $GRAFANA_API_KEY

>> [LOG] Getting the list of words to ignore when scraping from Grafana
Expand Down
4 changes: 3 additions & 1 deletion docker-compose/deploy_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ generate_apikey(){
--data '{"name":"local","role":"Viewer","secondsToLive":86400}' \
http://localhost:3000/api/auth/keys | jq -r .key)
echo $apikey
[[ ! -z $FRIGGA_TESTING ]] && echo $apikey > .apikey
echo $apikey > .apikey && echo ">> API Key was saved in .apikey file"
echo ">> Export the key as environment variable for later use"
echo "export GRAFANA_API_KEY=${apikey}"
}

grafana_update_admin_password(){
Expand Down
7 changes: 4 additions & 3 deletions scripts/grafana.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_metrics_list(base_url, api_key):
base_url
).json()
data = {
"dashboards": {}
"dashboards": dict()
}
for dashboard in dashboards:
dashboard_body = grafana_http_request(
Expand All @@ -91,8 +91,9 @@ def get_metrics_list(base_url, api_key):
dashboard_name = dashboard_body['meta']['slug'] if 'slug' in dashboard_body[
'meta'] and dashboard_body['meta']['slug'] else "null"
print_msg(msg_content=f"Getting metrics from {dashboard_name}")
expressions = scrape_value_by_key(dashboard_body, "expr", str)
expressions += scrape_value_by_key(dashboard_body, "query", str)
expressions = \
scrape_value_by_key(dashboard_body, "expr", str, []) \
+ scrape_value_by_key(dashboard_body, "query", str, [])
dashboard_metrics = []
for expression in expressions:
try:
Expand Down

0 comments on commit 74045c7

Please sign in to comment.