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

Allow specifying a data source input #83

Merged
merged 3 commits into from
Oct 16, 2017
Merged

Conversation

atopuzov
Copy link
Contributor

@atopuzov atopuzov commented Oct 11, 2017

  • Allows creation of dashboards which parametrise the input datasource [1]

Python code

...
dashboard = Dashboard(
    inputs=[
        DataSourceInput(
            name="DS_PROMETHEUS",
            type="datasource",
            label="Prometheus",
            pluginId="prometheus",
            pluginName="Prometheus"
        )],
...

Generated JSON

...
  "__inputs": [
    {
      "description": "",
      "label": "Prometheus",
      "name": "DS_PROMETHEUS",
      "pluginId": "prometheus",
      "pluginName": "Prometheus",
      "type": "datasource"
    }
  ],
...

Python code

...
    inputs=[
        ConstantInput(
            name="VAR_PREFIX",
            label="prefix",
            value="collectd"
        ),
...

Generated JSON

...
  "__inputs": [
    {
      "description": "",
      "label": "prefix",
      "name": "VAR_PREFIX",
      "type": "constant",
      "value": "collectd"
    },
...

[1] http://docs.grafana.org/reference/export_import/

* Allows creation of dashboards which parametrise the input datasource
@jml
Copy link
Contributor

jml commented Oct 16, 2017

Thanks!

This seems pretty useful, but I'm a bit wary of introducing inheritance into grafanalib. We've managed to avoid it so far and I think that's for the best.

Do you have ideas about how we could do this without it?

@atopuzov
Copy link
Contributor Author

It is only 2 attributes, so no much duplication. Also attr lib did not play well with inheritance (eg. description had to be copied as it has a default).

I'll just remove inheritance and push the change.

@atopuzov
Copy link
Contributor Author

@jml Pushed the changes without inheritance

@jml jml mentioned this pull request Oct 16, 2017
Copy link
Contributor

@jml jml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@jml jml merged commit c6312aa into weaveworks:master Oct 16, 2017
@atopuzov atopuzov deleted the inputs branch October 16, 2017 22:25
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

Successfully merging this pull request may close these issues.

2 participants