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

Add cloudwatch Target #184

Closed
wants to merge 5 commits into from

Conversation

uritau
Copy link
Contributor

@uritau uritau commented Oct 20, 2019

What does this do?

This PR adds a Cloudwatch Target to simplify the usage of Cloudwatch datasource.
.

Why is it a good idea?

This allows users to use Cloudwatch datasource with specific target (limiting and simplifiying the call) and doesn't interferes with anything else on grafanalib.

Questions

  • There is no test for this set, I will start working on it ASAP.
  • I feel that hardcoding here the validNamespaces and validRegions is not the best approach, but I haven't been able to find any AWS API to gather this information without registering in AWS :( so that's why exists the checkParams, with false this will not be updated.

Usage example

from grafanalib.core import *
from grafanalib.cloudwatch import CloudwatchTarget


dashboard = Dashboard(
    title="Clowdwatch Stats",
    rows=[
        Row(panels=[
            Graph(
                title="Cloudwatch ASG",
                dataSource='Cloudwatch',
                targets=[
                    CloudwatchTarget(
                        dimensions={
                            "AutoScalingGroupName": "frontend-asg-name",
                        },
                        metricName="CPUUtilization",
                        namespace="AWS/EC2",
                        region="eu-west-1",
                        statistics=["Average"],
                    ),
                ],
                yAxes=[
                    YAxis(format=PERCENT_UNIT_FORMAT),
                    YAxis(format=SHORT_FORMAT),
                ],
            ),
        ]),
    ],
).auto_panel_ids()

@atreyd
Copy link

atreyd commented Nov 12, 2019

When can we expect this feature to be merged. I am looking forward to use this feature for creating the AWS cloudwatch dashboards using grafanalib.

@@ -7,7 +7,7 @@
envlist = py27, py35, py37

[testenv]
commands = pytest --junitxml=test-results/junit-{envname}.xml
commands = pytest -o junit_family=xunit2 --junitxml=test-results/junit-{envname}.xml
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating to new junit_family, related with:
pytest-dev/pytest#6179

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this a separate PR maybe? It definitely makes sense:

.tox/py37/lib/python3.7/site-packages/_pytest/junitxml.py:436
  /home/daniel/dev/grafanalib/.tox/py37/lib/python3.7/site-packages/_pytest/junitxml.py:436: PytestDeprecationWarning: The 'junit_family' default value will change to 'xunit2' in pytest 6.0.
  Add 'junit_family=xunit1' to your pytest.ini file to keep the current format in future versions of pytest and silence this warning.
    _issue_warning_captured(deprecated.JUNIT_XML_DEFAULT_FAMILY, config.hook, 2)

Copy link
Contributor

Choose a reason for hiding this comment

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

Moved it to #236

"AWS/WorkSpaces",
]

validRegions = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to use something like https://stackoverflow.com/a/38451512 here?

@dholbach
Copy link
Contributor

dholbach commented Mar 6, 2020

Just a quick PSA from me:

  1. we're hanging out in #grafanalib on Slack
  2. we're planning a contributors meeting soon: here's the link to the doodle to find a good time - be sure to pick your timezone before submitting (preliminary agenda)

We'd love to see you there.



dashboard = Dashboard(
title="Clowdwatch Stats",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo here but it's inconsequential

@matthewmrichter
Copy link
Collaborator

@uritau - Please review the circlci tests, it looks like you'll need to make some formatting changes to pass the tests.

Copy link
Collaborator

@matthewmrichter matthewmrichter left a comment

Choose a reason for hiding this comment

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

Please check CircleCI

kevinatomwise added a commit to kevinatomwise/grafanalib that referenced this pull request Sep 22, 2020
if self.checkParams:
self.__checkParameters()

return {
Copy link

Choose a reason for hiding this comment

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

dict.update returns None (https://docs.python.org/3/library/stdtypes.html#dict.update) which means that the target json ends up being null.

@dholbach
Copy link
Contributor

Thanks again for your PR. It's been a while since we reviewed this. We'll close the PR for now as grafanalib mainline has already moved on a bit. Please reopen the PR if you (or anyone else) wants to move this work forward again. We're also happy to chat with you on Slack if you have any questions.

@dholbach dholbach closed this Nov 20, 2020
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.

None yet

6 participants