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

to=/from= formats? #56

Open
senpro-ingwersenk opened this issue Sep 16, 2024 · 1 comment
Open

to=/from= formats? #56

senpro-ingwersenk opened this issue Sep 16, 2024 · 1 comment

Comments

@senpro-ingwersenk
Copy link

Hello there!

I am almost done writing the report automation; it took forever to get the information I wanted out of Grafana... Last step now is to set the start and end time of the time window for which the report should be generated.

I saw some descriptions here:
https://github.com/divinity666/ruby-grafana-reporter/blob/master/lib/grafana_reporter/asciidoctor/help.rb#L156-L166

From looking at the logs, Grafana sends momentjs-ish timestamps:

D, [2024-09-16T07:36:06.937966 #7] DEBUG -- : query_parameters: {"from"=>["now-1h"], "to"=>["now"], "var-datasource"=>["senst-microsoft"], "var-bucket"=>["microsoft"], "var-host"=>["SENCS-SV-HV1"], "var-template"=>["senstMicrosoftWindowsServer"]}

When I pass time values myself, do I just pass them as ISO formatted values? My goal is to preset the start and end to the start and end of a month to generate monthly reports.

You can find my current client implementation here: https://github.com/senpro-it/grafana-report-generator/blob/master/grafana-ruby-reporter-client.go

It's far from done, but I am actively working on it. According to our ticketing system I already put roughly 50 hours into this, most of this however was prep and research. Still, I hope to finish this project soon. :)

Thank you and kind regards!

@divinity666
Copy link
Owner

You can find the code for the datetime parsing here:

# Used to translate the relative date strings used by grafana, e.g. +now-5d/w+ to the

You may provide UTC times or the grafana relative time expressions. For current month you can provide something like now-M/M or now-1M/M for previous month as to and from times.

Hope this helps.

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

No branches or pull requests

2 participants