Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Add support for dashboard and panel ids #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rrey
Copy link
Owner

@rrey rrey commented Nov 10, 2018

No description provided.

@ageis
Copy link

ageis commented Nov 12, 2018

Thanks a lot for implementing this. I'm getting "Grafana answered with HTTP 302", can we make redirects a valid status code for fetch_url, and also control validate_certs?

Taking HTTPS off the URI results in "unknown url type: grafana.redacted.com/api/annotations?tags=ansible&from=1542054051000&to=1542054056000"... I think we need to allow 301/302 for certain reverse proxy setups.

@rrey
Copy link
Owner Author

rrey commented Nov 13, 2018

Since the module uses the ansible helper fetch_url there is a couple of params supported by the module. You can see the list here: https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/urls.py#L1177

So validate_certs is already supported by the module, just add it in your params.

Taking HTTPS off the URI results in "unknown url type: grafana.redacted.com/api/annotations?> tags=ansible&from=1542054051000&to=1542054056000"... I think we need to allow 301/302 for certain reverse proxy setups.

I think the underlying code requires the http/https in the url to determine if a secure ssl connection should be use. I can't change that in the callback.

I think we need to allow 301/302 for certain reverse proxy setups.

The fetch_url helper seems to support a follow_redirects that can be provided in the mode parameters. I need to add it in the ArgumentSpec.
I'll check this when I have time.

@ageis
Copy link

ageis commented Nov 13, 2018

@rrey Cool... Tried to figure out how to patch fetch_url with that RedirectHandlerFactory on my own but haven't had any luck yet. I'll be here ready to test!

Came up with this, still fails with "HTTP Error 302: Found"

        opener = urllib_request.build_opener(RedirectHandlerFactory(follow_redirects=True, validate_certs=False))
        urllib_request.install_opener(opener)
        data = to_bytes(annotation.json, nonstring='passthru')
        request = RequestWithMethod(self.url, method="GET", data=annotation.json)
        for header in self.headers:
            request.add_header(header, self.headers[header])
        urlopen_args = [request, None]
        resp, info = urllib_request.urlopen(*urlopen_args)

@ageis
Copy link

ageis commented Nov 14, 2018

@rrey It turns out the redirect thing was a peculiarity of my particular Grafana environment, so don't worry about it! We had to put in an exception to bypass SAML/SSO login for the /api/* URI. I'll let you know once I've successfully tested this commit/PR.

@rrey
Copy link
Owner Author

rrey commented Jan 15, 2019

Hey @ageis
Did you manage to test this ?

@rrey rrey force-pushed the add-panel-dashboard-ids branch from 8aa0866 to bf1c216 Compare March 3, 2022 07:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants