Commit graph

9 commits

Author SHA1 Message Date
Matias Bordese
6a65ddd6e7
feat: add timestamp_to_datetime jinja template filter (#5303)
Related to https://github.com/grafana/support-escalations/issues/13670

Given a payload like this:

```
{  
    "Sometime": "1730893740"  
}
```

the following template expression:

`{{ payload.Sometime | int | timestamp_to_datetime }}`

will render as:

`2024-11-06 11:49:00`
2024-11-28 11:20:21 +00:00
Jack Baldry
336b924a08
Fix first heading level (#5269) 2024-11-20 10:05:03 +00:00
Nick Moore
cf589d45c6
feat: add timedeltaparse function to the jinja template (#5142)
# What this PR does
If an OnCall template needs to contain a date relative to a date in the
alert response, currently there is no way for the template to add or
subtract time from a parsed date.

This PR adds a function that allows a time-window (e.g., 1s, 5m, 6h, 7d,
2w) to be converted into a Python timedelta, which can then be added or
subtracted from a datetime. An example usage might be:

```
{% set delta = alert.timeWindow | timedeltaparse %}
{% set time = alert.startsAt | iso8601_to_time - delta | datetimeformat('%s') %}
```

## Checklist

- [X] Unit, integration, and e2e (if applicable) tests updated
- [X] Documentation added (or `pr:no public docs` PR label added if not
required)
- [X] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will show up in the
autogenerated release notes.
2024-10-09 18:27:48 +00:00
Matias Bordese
0fa3522db7
Add doc references to regex_search jinja filter (#4973)
This filter wasn't listed in cheatsheet or docs, but it is usually more
flexible/simpler than `regex_match` if trying to search for a substring
in payload.

Also setup a
[timeout](https://github.com/mrabarnett/mrab-regex?tab=readme-ov-file#timeout)
when regex searching/matching/replacing.

Related to [this
issue](https://docs.google.com/document/d/1gESMLdbJSnLnSnK7Nhp7DvJ7f10qZXsEm5GrgBc5RqQ/edit)
2024-09-04 17:47:09 +00:00
Jack Baldry
9ae442faa6
Replace docs/reference shortcode with ref URIs (#4301)
You can use `ref` URIs in admonitions (or any shortcodes) because they
are inline and not subject to the issues noted in the [`admonition`
shortcode](https://grafana.com/docs/writers-toolkit/write/shortcodes/#code-shortcode:~:text=to%20core%20understanding.-,WARNING,For%20more%20information%2C%20refer%20to%20Markdown%20Reference%20Links%20in%20Shortcodes.,-Examples).

The `ref` URIs perform the same pattern matching as `docs/reference` but
don't require the use of reference-style links and the destinations are
ordinary (full) URLs that can include version substitution. Unlike
`docs/reference`, the implementation doesn't use `relref` so you don't
have to be careful with omitting trailing slashes and the links will
follow redirects.

Documentation:
https://grafana.com/docs/writers-toolkit/write/links/#link-from-source-content-thats-used-in-multiple-projects

To check the links, refer to the deploy preview in
https://github.com/grafana/website/pull/19630.

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>

---------

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
2024-07-29 14:13:24 +00:00
Alyssa Wada
87dd4f90ad
refactor docs configuration section (#4646)
# What this PR does
Restructures OnCall documentation 'Configure' section 

## Which issue(s) this PR closes
Closes issue #4592
2024-07-25 15:22:39 +00:00
jorgeav
dba6748efd
Add datetimeparse Jinja2 template helper filter function (#4312)
# What this PR does
Jinja2 filter to parse strings into datetime objects. Previously, only a
limited set of strings could be parsed into datetime objects
([datetime_re](https://docs.djangoproject.com/en/2.2/_modules/django/utils/dateparse/)).

The addition of this filter allows for strings of any format to be
converted into datetime.

## Which issue(s) this PR closes


<!--
*Note*: if you have more than one GitHub issue that this PR closes, be
sure to preface
each issue link with a [closing
keyword](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/using-keywords-in-issues-and-pull-requests#linking-a-pull-request-to-an-issue).
This ensures that the issue(s) are auto-closed once the PR has been
merged.
-->

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] Added the relevant release notes label (see labels prefixed w/
`release:`). These labels dictate how your PR will
    show up in the autogenerated release notes.

Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
2024-05-13 17:16:38 +00:00
Karim Darwish
2a46e4ff84
Add parse_json template function (#3929) 2024-02-20 10:29:03 -05:00
Alyssa Wada
80f932995c
oncall docs refactor (#3757)
# What this PR does

- Restructure the OnCall documentation to align with Grafana Labs
[documentation structure
guidance](https://grafana.com/docs/writers-toolkit/structure/).

- Updates documentation front matter to include all required fields.

## Which issue(s) this PR fixes
Related to issue #3700 

## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
2024-02-08 22:59:28 +00:00