-
Notifications
You must be signed in to change notification settings - Fork 319
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 support for Elasticsearch datasource #99 #100
Conversation
@jml any chance to get the PR merged? |
I've scheduled tomorrow for doing grafanalib stuff.
…On Thu, 4 Jan 2018 at 17:12 Fabian Holler ***@***.***> wrote:
@jml <https://github.com/jml> any chance to get the PR merged?
It would be great to have the elasticsearch support in the upstream version
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#100 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHq6owDouGTc6BQnzF0aNTEDDIpNF8cks5tHQZogaJpZM4RKDWq>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I've got a couple of bigger changes I'd like you to make and a few smaller things. Let me know if you've got questions.
grafanalib/elasticsearch.py
Outdated
|
||
@attr.s | ||
class DateTimeAgg(object): | ||
field = attr.ib(default="time_iso8601", validator=instance_of(str)) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
class DateTimeAgg(object): | ||
field = attr.ib(default="time_iso8601", validator=instance_of(str)) | ||
id = attr.ib(default=0, validator=instance_of(int)) | ||
settings = attr.ib(default=DateTimeAggSettings()) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
'id': str(self.id), | ||
'settings': self.settings, | ||
'type': self.type | ||
} |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
|
||
@attr.s | ||
class CountMetric(object): | ||
field = attr.ib(default="select field", validator=instance_of(str)) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
@attr.s | ||
class CountMetric(object): | ||
field = attr.ib(default="select field", validator=instance_of(str)) | ||
type = attr.ib(default="count", validator=instance_of(str)) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
""" | ||
|
||
alias = attr.ib(default=None) | ||
bucket_aggs = attr.ib(default=[DateTimeAgg()]) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
if agg.id: | ||
return agg | ||
|
||
agg.id = next(auto_ids) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
def to_json_data(self): | ||
return { | ||
'alias': self.alias, | ||
'bucketAggs': self.auto_bucket_aggs_id(), |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
refId = attr.ib(default="", validator=instance_of(str)) | ||
|
||
def auto_bucket_aggs_id(self): | ||
ids = set([agg.id for agg in self.bucket_aggs if agg.id]) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -0,0 +1,65 @@ | |||
from grafanalib.core import * |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@jml thanks a lot for you feedback. I'll address your remarks soon. |
Add an ElasticsearchTarget and query related helper classes to create graphs with queries from an elasticsearch datasource. This commit only adds partial support for elasticsearch queries. Grafana supports a lot more Metric and Aggregators for elasticsearch.
@jml
In the current PR version metric aggregators have the postfix What naming would you prefer? |
- add documentation - improve naming - remove Settings objects, move the fields to the aggregator objects - make fields that don't change constants in to_json_data()
@jml I addressed all your comments and did some additional refactoring. |
Will do, thanks!
…On Wed, 14 Feb 2018 at 18:11 Fabian Holler ***@***.***> wrote:
@jml <https://github.com/jml> I addressed all your comments and did some
additional refactoring.
Please review it again
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#100 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHq6vJ0ieKyh9eIJI2v0gWFphi_IDcVks5tUyHigaJpZM4RKDWq>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thank you so much for sticking with this.
All my comments are very minor, so I'll fix them up myself and then merge this.
@@ -0,0 +1,75 @@ | |||
""" | |||
This is an exemplary Grafana board that uses an elastichsearch datasource. | |||
The graph shows the followinging metrics for HTTP requests to the URL path "/login": |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
""" | ||
This is an exemplary Grafana board that uses an elastichsearch datasource. | ||
The graph shows the followinging metrics for HTTP requests to the URL path "/login": | ||
- number of succesful requests resulted in a HTTP response code between 200-300 |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
) | ||
|
||
dashboard = Dashboard(title="HTTP dashboard", | ||
rows=[Row(panels=[g])]) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
grafanalib/elasticsearch.py
Outdated
@@ -0,0 +1,207 @@ | |||
"""Helpers to create Elasticsearch specific Grafana Queries.""" |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
The PR adds partial support for creating graphs against an elasticsearch datasource.
It only adds support for basic query and aggregators.
Grafana supports more aggregators and query options that are not implemented yet.