Skip to content

Conversation

@guhanjie
Copy link

Summary

Implemented support for Grafana MySQL-style macros to simplify query writing for SLS datasource.

Changes

  • Added pkg/macros.go: Implements InterpolateMacros function to parse and replace macros.
  • Modified pkg/sls-plugin.go: Integrated macro interpolation into the QueryLogs flow.

Supported Macros

  • $__time(__time__) -> to_unixtime(__time__) as time
  • $__timeFilter(__time__) -> __time__ >= from AND __time__ < to
  • $__timeGroup(__time__, '5m', [fill]) -> time_series(__time__, '5m', '%Y-%m-%d %H:%i:%s', fill)
  • $__timeGroupAlias(__time__, '5m') -> time_series(...) as time

PS: __time__ is built-in time field in SLS log

Change-Id: I1011010944f20f14a21721f4a32112dea5e61731
Co-developed-by: Cursor <[email protected]>
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


执少 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants