Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
dashboards: Make the regex much more specific
Browse files Browse the repository at this point in the history
To make sure that we're not being too greedy with the regex
replacement of the data source to use for each dashboard
that's uploaded, we make it much more specific using the
following:

- literal boundaries for " on either side of the match
- non-capturing optional group matches for the ${} bits
- the case-sensitive literal match for DS_ which is
  always in every exported dashboard representing the
  data source used
- a one-or-more case-sensitive match for the part that
  follows the underscore, with no characters allowed
  except alphabetical

This should prevent mistaking any capitalised labels or
anything else which may be present in the dashboard.
  • Loading branch information
Jesse Pretorius committed Mar 22, 2018
1 parent c9d97ca commit d2e3fa5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tasks/dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
become: no
replace:
dest: "/tmp/dashboards/{{ item.dashboard_id }}.json"
regexp: "[$].DS_.*}"
replace: "{{ item.datasource }}"
regexp: '"(?:\${)?DS_[A-Z]+(?:})?"'
replace: '"{{ item.datasource }}"'
delegate_to: localhost
run_once: yes
with_items: "{{ grafana_dashboards }}"
Expand Down

0 comments on commit d2e3fa5

Please sign in to comment.