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

Variable parsing dot char issue #174

Open
manueligno78 opened this issue Oct 23, 2019 · 2 comments
Open

Variable parsing dot char issue #174

manueligno78 opened this issue Oct 23, 2019 · 2 comments

Comments

@manueligno78
Copy link
Contributor

Variable parsing fails when the variable contains a dot char inside:

- name: Test Project
  project:
    expression_variable: metricname{{label="plain_label_value", regex_label~=".*teststring.*"}}
    dashboards:
      - TestDashboard

- name: TestDashboard
  dashboard:
    title: 'TestDashboard'
    rows:
      - row:
          title: 'row'
          panels:
            - graph:
                target: '{expression_variable}'

Produce this output:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/bin/grafana-dashboard-builder", line 11, in <module>
    load_entry_point('grafana-dashboard-builder==0.5.0a2', 'console_scripts', 'grafana-dashboard-builder')()
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/cli.py", line 106, in main
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/exporter.py", line 54, in process_projects
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/components/base.py", line 140, in gen_json
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 59, in expand_placeholders
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 57, in expand_placeholders
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 59, in expand_placeholders
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 59, in expand_placeholders
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 57, in expand_placeholders
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 59, in expand_placeholders
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 59, in expand_placeholders
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 51, in expand_placeholders
  File "build/bdist.macosx-10.6-intel/egg/grafana_dashboards/context.py", line 69, in _expand
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 563, in vformat
    result = self._vformat(format_string, args, kwargs, used_args, 2)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 585, in _vformat
    obj, arg_used = self.get_field(field_name, args, kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/string.py", line 652, in get_field
    obj = getattr(obj, i)
AttributeError: 'unicode' object has no attribute '*teststring'
@manueligno78
Copy link
Contributor Author

This is the "workaround" I am using at the moment:

expression_variable: metricname{{{{label="plain_label_value", regex_label~=".*teststring.*"}}}}

Should be nice a more specific paragraph on READ.me about "{{{{" and "}}}}" use cases.

@jammerful
Copy link

Also ran into this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants