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 per-query tenant configuration #85

Merged
merged 5 commits into from
Jul 27, 2017
Merged

Conversation

jotak
Copy link
Collaborator

@jotak jotak commented Jul 24, 2017

Feat. #62
Notes:

  • There's a limitation with templating vars. I'm not sure that grafana allows to edit that screen layout. A solution for later would be to somehow integrate the tenant in the query string, but that requires a little more reflection, so I'll open another ticket for that
  • In the same time I've added the ability to fetch availability metrics in annotations (very little work was needed)

Feat. hawkular#62
Notes:
- There's a limitation with templating vars. I'm not sure that grafana allows to edit that screen layout. A solution for later would be to somehow integrate the tenant in the query string, but that requires a little more reflection, so I'll open another ticket for that
- In the same time I've added the ability to fetch availability metrics in annotations (very little work was needed)
@jotak
Copy link
Collaborator Author

jotak commented Jul 24, 2017

"Don't merge yet" => I must add unit tests first

@jotak
Copy link
Collaborator Author

jotak commented Jul 25, 2017

I've done some refactoring on tests, splitting the huge "datasource_spec" into several files. Maybe it's going to be easier to review commit by commit

// If tenants is unknown at this point (when having per-query tenants)
// We do a more basic check to status endpoint
// Else, it's full connectivity with tenant check
const endpoint = this.isTenantPerQuery ? '/status' : '/metrics';
Copy link
Collaborator

Choose a reason for hiding this comment

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

The thing is that the status endpoint might be reachable even without the proper credentials

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, but I can't see other way round. In openshift for example authentication is closely linked to the tenant, so it cannot be checked anyway at this step.

@tsegismont
Copy link
Collaborator

tsegismont commented Jul 25, 2017 via email

Unlike /status this endpoint requires auth in basic-auth mode, though not with openshift (special message is then displayed)
@jotak
Copy link
Collaborator Author

jotak commented Jul 26, 2017

@tsegismont I think I've found a good compromise, testing on "/" endpoint is better than "/status" as I noticed that in this case authentication is required in basic-auth mode.
Still for token-based auth in openshift, there's no authentication on this endpoint, so I added a warning message in this case.

@tsegismont
Copy link
Collaborator

Have you checked what happens when tenant is query specific and authentication is misconfigured? Is the error message displayed on the graph top-left corner informative?

@jotak
Copy link
Collaborator Author

jotak commented Jul 26, 2017

It's informative... as long as the server provides informative response.

If I put a valid oauth token but coupled with unauthorized tenant, it shows a 403 forbidden as expected.

However if I put an invalid oauth token, I get a 500 internal server error, which is not very meaningful. It seems to be an Hawkular issue, because I don't see the same behaviour when reaching OS rest api

For example, curl -H "Authorization: Bearer faketoken" https://192.168.1.29:8443/oapi/v1 -k
returns "Unauthorized"
whereas curl -H "Hawkular-Tenant: test" -H "Authorization: Bearer faketoken" https://metrics-openshift-infra.192.168.1.29.xip.io/hawkular/metrics/metrics -k
returns 500 error

Anyway this is a server-side issue. I'll investigate more on that but I think it shouldn't block this PR.

@jotak
Copy link
Collaborator Author

jotak commented Jul 26, 2017

PS: the error is displayed in the upper left corner as you expect

@tsegismont
Copy link
Collaborator

Alright.

I don't have any other comment.

👍

@jotak
Copy link
Collaborator Author

jotak commented Jul 27, 2017

Thanks, by the way JIRA has been filed for the error 500: https://issues.jboss.org/browse/HWKMETRICS-709

@jotak jotak merged commit 679f2f3 into hawkular:master Jul 27, 2017
@ljuaneda
Copy link

ljuaneda commented Sep 8, 2017

when do you plan to release this one so we can pull it through docker.io ?

@jotak
Copy link
Collaborator Author

jotak commented Sep 8, 2017

@ljuaneda sounds like a good task for a friday afternoon

@jotak
Copy link
Collaborator Author

jotak commented Sep 8, 2017

Done: https://hub.docker.com/r/hawkular/hawkular-grafana-datasource/tags/
Note that, as per release note (https://github.com/hawkular/hawkular-grafana-datasource/releases/tag/v1.1.0) , you will have to update existing datasource configs to remove the /metrics path at the end of the server URL.

@ljuaneda
Copy link

ljuaneda commented Sep 8, 2017

Ok thanks, I'll a quick test and let you know if there is any pb

@alekonko
Copy link

alekonko commented Sep 8, 2017

hi how do put tenant (ocp projects) into templating ?

@ljuaneda
Copy link

It doesnt seem possible to set the tenant from a variable...

@jotak
Copy link
Collaborator Author

jotak commented Sep 11, 2017

@alekonkoisp @ljuaneda no, you cannot put a tenant into templating unfortunately (I mentioned it in the first bullet point of this PR above). Grafana API doesn't allow to customize the templating view, so you still need to have a fixed tenant in DS config to use templating I fear :(

@ljuaneda
Copy link

ljuaneda commented Sep 12, 2017

Sorry, If we misunderstood, I was not talking about the templating view.
To be clear, I have already a variable getting the kubernetes namespaces (from a prometheus datasource )
We'd like to use that variable for the tenant in the graph aera

@jotak
Copy link
Collaborator Author

jotak commented Sep 12, 2017

I see, I misunderstood. I've just opened an issue ( #90 )

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.

4 participants