You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hertzbeat.apache.org by "LiuTianyou (via GitHub)" <gi...@apache.org> on 2024/05/13 15:02:56 UTC
[D] Support relative time calculation expressions [hertzbeat]
GitHub user LiuTianyou created a discussion: Support relative time calculation expressions
Hello, community
#### Backgroud
When we use SQL to query metrics, we can use expressions like `NOW() - INTERVAL 1 HOUR` to calculate the time one hour ago. However, when querying metrics through other protocols, such as using the HTTP protocol, it is not possible to pass relative time by defining request parameters.
For example, in the OpenAI monitoring, the `/dashboard/billing/usage` endpoint requires two time parameters, `startDate` and `endDate`. Due to the inability to support dynamic time calculation expressions, we have to hardcode the logic in the code to add the corresponding parameters based on the URL.
Suggestion: Add global time calculation expressions.
#### What problem does it solve:
- Users can customize dynamic time parameters and participate in metric queries.
For example:
- `@now` gets the current time formatted as `yyyy-MM-dd HH:mm:ss`
- `@date` gets the current date formatted as `yyyy-MM-dd`
- `@time` gets the current time formatted as `HH:mm:ss`
- `@timestamp` gets the current 13-digit timestamp
- `@now-1d` gets the time at the same point yesterday
- `@now-1m` gets the time one minute ago
- `@now+2w` gets the time two weeks later
- ...
#### How to use:
- Use `^_^expression^_^`, for example, `^_^@now-1d^_^`
#### Where can expressions be used:
- Anywhere `^_^XXX^_^` placeholders are supported.
GitHub link: https://github.com/apache/hertzbeat/discussions/1979
----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org
Re: [D] Support relative time calculation expressions [hertzbeat]
Posted by "LiuTianyou (via GitHub)" <gi...@apache.org>.
GitHub user LiuTianyou added a comment to the discussion: Support relative time calculation expressions
As you said, the time expression should be calculated where it is used, so we first consider supporting `time calculation` in the request params of the HTTP protocol.Should we consider using other placeholders such as ${}? This would be less likely to be confused with the ones defined in congfigmap.
GitHub link: https://github.com/apache/hertzbeat/discussions/1979#discussioncomment-9422941
----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org
Re: [D] Support relative time calculation expressions [hertzbeat]
Posted by "zqr10159 (via GitHub)" <gi...@apache.org>.
GitHub user zqr10159 added a comment to the discussion: Support relative time calculation expressions
Good idea
GitHub link: https://github.com/apache/hertzbeat/discussions/1979#discussioncomment-9422714
----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org
Re: [D] Support relative time calculation expressions [hertzbeat]
Posted by "tomsun28 (via GitHub)" <gi...@apache.org>.
GitHub user tomsun28 added a comment to the discussion: Support relative time calculation expressions
Good idea!👍 Now we deal the `^_^` in method org.apache.hertzbeat.collector.util.CollectUtil#replaceSmilingPlaceholder, suggest when deal the `time calculation`, do not pre put the dynamic time in `configmap`, because most monitoring probably won't use it, we can calculate time expression when this time expression is used.
GitHub link: https://github.com/apache/hertzbeat/discussions/1979#discussioncomment-9422701
----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org