58 Commits

Author SHA1 Message Date
ca51127592 POST /loki/api/v1/push should not be on query path (#9220)
POST /loki/api/v1/push is on the write path on the distributor and
should not be the query frontend (read path)
2023-04-21 17:00:52 +02:00
abd6131bba Update prepare shutdown (#9175)
**What this PR does / why we need it**:

This updates the PrepareShutdown method so it supports GET and DELETE
methods as well. This makes it similar to Mimir:
https://github.com/grafana/mimir/pull/4718.
The status is now stored in a local file. A new config setting had to be
added for this file as there is no obvious place to store it.


**Checklist**
- [X] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [X] Documentation added
- [X] Tests updated
- [x] `CHANGELOG.md` updated
- [x] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`

---------

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>
Co-authored-by: Dylan Guedes <djmgguedes@gmail.com>
2023-04-19 16:17:37 +01:00
e050d5c494 Docs: Update Loki GitHub URLs (#9080)
* use `main` instead of `master` branch
* fix outdated URLs
2023-04-14 07:52:55 -06:00
cce3d3bed9 chore(format_query): Change response type to application/json (#9016) 2023-04-04 19:42:17 +02:00
09f23ecd03 Docs: Improve time range documentation (#8847)
**What this PR does / why we need it**:

Describes how exactly the `start` and `end` timestamps operate on the
time range boundaries.

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added

---------

Co-authored-by: J Stickler <julie.stickler@grafana.com>
2023-03-31 11:13:34 -06:00
1bcf683513 Expose optional label matcher for label values handler (#8824) 2023-03-30 15:26:06 +02:00
53b9a351e5 Loki: Add a prepare-shutdown endpoint (#8786)
**What this PR does / why we need it**:
Add a new `/ingester/prepare_shutdown` endpoint. This new endpoint
configures the ingester to release resources on the next SIGTERM.

---------

Co-authored-by: J Stickler <julie.stickler@grafana.com>
2023-03-17 15:08:35 -06:00
3cb15d62d5 Docs: Add doc-validator tool to lint technical documentation (#6569)
Source code:

https://github.com/grafana/technical-documentation/tree/main/tools/doc-validator

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

**What this PR does / why we need it**:

Adds a CI step for pull requests that validates links in technical
documentation and performs linting of technical documentation source
files.

**Special notes for your reviewer**:

- Lots of issues will need to be fixed before we can merge this.
- The tool is still in early development so each error should be
scrutinized for validity.

**Checklist**
- [ ] Documentation added
- [na] Tests updated
- [na] Is this an important fix or new feature? Add an entry in the
`CHANGELOG.md`.
- [na] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
2023-01-19 10:55:12 +01:00
2b66c6b126 Loki: add a 'since' query parameter for easier querying using relative time (#7964)
Signed-off-by: Edward Welch <edward.welch@grafana.com>

**What this PR does / why we need it**:

logcli has a command line parameter called `since` which makes it easy
to query logs relative to the current time, however this is some
syntactic sugar used in logcli to calculate `start` and `end` query
parameters for the query sent to Loki.

This PR adds native support for a `since` query parameter to make it a
little easier to consume the Loki query API without having to calculate
precise start/end times with every request.

This is useful if you are polling the Loki API from a third party app
which doesn't let you easily build dynamic URL's and all you want to do
is poll for say the last 3 hours of logs.

**Which issue(s) this PR fixes**:
Fixes #<issue number>

**Special notes for your reviewer**:

**Checklist**
- [x] Reviewed the `CONTRIBUTING.md` guide
- [x] Documentation added
- [x] Tests updated
- [x] `CHANGELOG.md` updated
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`

Signed-off-by: Edward Welch <edward.welch@grafana.com>
Co-authored-by: Owen Diehl <ow.diehl@gmail.com>
2023-01-05 11:32:45 -06:00
cbd6ec15ce feat(logql): Supporting prettifying LogQL expressions (#7906)
**What this PR does / why we need it**:

Changes
1. Added `Pretty()` method to `Expr` interface. So that every expression
would know how to render themselfs as pretty :)
2. Implemented `Pretty()` for every single LogQL expressions
3. Exposed `/api/v1/format_query` endpoint that takes `query` argument
and returns formatted version.
4. Integerated into `logcli`. echo `'<query>' | logcli fmt` would format
the query.

Why?
1. Readability, helpful in debugging and **more importantly, to
understand the execution flow**

example

**before**
```
quantile_over_time(0.99,{container="ingress-nginx",service="hosted-grafana"}| json| unwrap response_latency_seconds| __error__=""[1m]) by (cluster)
```

```
sum(rate({job="loki", namespace="loki", cluster="loki-dev-us"} |= "err" [5m])) + sum(rate({job="loki-dev", namespace="loki", cluster="loki-dev-eu"}|logfmt | level != "info" [5m])) / sum(rate({job="loki-prod", namespace="loki", cluster="loki-prod-us"} |logfmt | level="error"[5m]))
```

```
label_replace(rate({job="api-server",service="a:c"}|= "err" [5m]), "foo", "$1", "service", "(.*):.*")
```

**after**
```
quantile_over_time(
  0.99,
  {container="ingress-nginx", service="hosted-grafana"} | json
    | unwrap response_latency_seconds
    | __error__="" [1m]
) by (cluster)

```

```
  sum(
    rate(
      {job="loki", namespace="loki", cluster="loki-dev-us"} |= "err" [5m]
    )
  )
+
    sum(
      rate(
        {job="loki-dev", namespace="loki", cluster="loki-dev-eu"}
          | logfmt
          | level!="info" [5m]
      )
    )
  /
    sum(
      rate(
        {job="loki-prod", namespace="loki", cluster="loki-prod-us"}
          | logfmt
          | level="error" [5m]
      )
    )

```

```
label_replace(
  rate({job="api-server", service="a:c"} |= "err"[5m]),
  "foo",
  "$1",
  "service",
  "(.*):.*"
)

```

You can find more examples in the `prettier_test.go`



Future plans
* Integerate into LogQL analyzer
* Integrate into Grafana UI.

**Which issue(s) this PR fixes**:
Fixes # NA

**Special notes for your reviewer**:
This whole idea was inspired from last [PromCon lighting
talk](https://youtu.be/pjkWzDVxWk4?t=24469)

**Checklist**
- [x] Reviewed the `CONTRIBUTING.md` guide
- [x] Documentation added
- [x] Tests updated
- [x] `CHANGELOG.md` updated

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Co-authored-by: Christian Haudum <christian.haudum@gmail.com>
Co-authored-by: Christian Simon <simon@swine.de>
2022-12-14 16:19:56 +01:00
4768b6d997 doc(api): Default value for delete_ring_tokens on /ingester/shutdown endpoint (#7921)
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>

**What this PR does / why we need it**:
PR documents the default value for `delete_ring_tokens` params on
`/ingester/shutdown` endpoint.

**Which issue(s) this PR fixes**:
Fixes #NA

**Special notes for your reviewer**:

**Checklist**
- [x] Documentation added

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
2022-12-13 22:16:22 +01:00
ef47e0ee8a Fix errors loading deletes after force-removing partially-completed delete (#7125)
When sharded deletes that are partially completed are force-removed,
everything is removed except the shards that are currently being
deleted. The shards being deleted aren't necessarily in numerical order
so there's no way to know assume which shards have and haven't been
deleted.

The Delete store assumed it could look up requests in sequential order
and returned empty requests where there were gaps in the stored data.
This change takes the `sequence number` from the stored key of the
delete requests it finds and uses that to look up details.
2022-09-09 13:38:28 -06:00
ebdb64b3f5 Small updates to the deletion documentation (#7112)
**What this PR does / why we need it**:

- Fix a typo
- Fix the links in for the deletion API 

**Checklist**
- [X] Documentation added
- [ ] Tests updated
- [ ] Is this an important fix or new feature? Add an entry in the
`CHANGELOG.md`.
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>
2022-09-09 09:50:27 +01:00
8da290cd2d Use backticks for code syntax. (#6967)
* Use backticks for code syntax.

* Fix for real. :)
2022-08-25 18:05:22 +02:00
e15da437f0 Shard deletes requests based on time ranges (#6903)
* Refactor the store API to be in terms of DeleteRequest

* backfill remove tests

* backfill GetAll tests

* Make the delete request store deal in groups of requests instead of single ones

* Make cancelation aware of request groups

* remove cancelation deadline

* shard deletes based on a query parameter

* merge request group on gets

* global configuration for max query range

* sort delete requests by start time so batches are grouped to similar chunks

* Fix status when some deletes haven't happened yet

* fix tests

* Review feedback

* review feedback

* make max_interval > deletion interval a validation error

* list partially completed deletes

* list partially completed deletes

* fix flaky test

* clarify naming

* disallow cancelation of partial deletes unless the 'force' flag is passed

* more comment specificity for the delete request hash
2022-08-24 08:45:00 -06:00
983ab80e7c Add delete api validations (#6860)
* break out the middleware

* Add validation to the API

- Time must be in RFC3339 or a 10-digit-unix-seconds timestamp
- Start time must always exist

* lint

* docs

* improve tests

* cleanup

* cleanup

* access runtime config via function on validation
2022-08-10 11:09:02 -06:00
5b432e3d99 Docs: Fix bad links in the API section (#6688)
* Docs: Fix a bad link in the API section

* Fix 2 more of the same bad link
2022-07-15 09:34:01 +01:00
1f676adf06 Add API delete curl examples (#6680)
* Add API delete curl examples

* Update docs/sources/api/_index.md

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>

* Update docs/sources/api/_index.md

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>

* Update docs/sources/api/_index.md

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>

* Update docs/sources/api/_index.md

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>

Co-authored-by: Jennifer Villa <jvilla2013@gmail.com>
2022-07-14 16:00:20 -05:00
92aa69bb5c Docs: Add multi-tenant query curl examples (#6530)
* Docs: Add multi-tenant query curl examples

* Revise per review suggestions.
2022-06-30 13:20:48 -07:00
27477bf5f5 Docs: improve API docs (#6485)
* Docs: improve API docs

* Implement review suggestions.
2022-06-28 12:44:22 -07:00
c12a1f4f43 feature: Add ingester handler for shutdown and forget tokens (#6179)
* Update grafana/dskit to 07166f9

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>

* Add /ingester/shutdown handler

This handler replaces the deprecated /ingester/flush_shutdown handler
and can be used to gracefully shut down a Loki instance and delete the
file that persists the tokens of the ingester ring.

In production environments you usually want to persist ring tokens so
that during a restart of an ingester instance, or during rollout, the
tokens from that instance are not re-distributed to other instances, but
instead kept so that the same streams end up on the same instance once
it is up and running again. For that, the tokens are written to a file
that can be specified via the `-ingester.tokens-file-path` argument.

In certain cases, however, you want to forget the tokens and
re-distribute them when shutting down an ingester instance. This was
already possible by calling `/ingester/flush_shutdown`, deleting the
tokens file and terminating the process. The new handler
`/ingester/shutdown` combines these manual steps into a
single handler.

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>

* Add changelog entry

Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
2022-06-14 15:44:01 +02:00
3f4a663dbe Tsdb/index sampling endpoint (#6347)
* index sampling endpoint

* fix bug in withTenantLabelMatcher

* show zero values in stats

* handles new errcase

* fixes comments
2022-06-09 13:53:31 -04:00
0075085e9a docs: describe ordering in http query results (#6024)
* docs: describe ordering in http query results

* improved text

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>

* better text

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>

* better text

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
2022-05-20 16:10:56 -04:00
f39552c7fa Add docs for updated deletion api (#5763)
* Add docs for updated deletion api

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>

* Fix parameter name

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>

* Clarify that only the delete requests for the current tenant are shown

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>

* Update docs/sources/api/_index.md

Co-authored-by: Christian Simon <simon@swine.de>

* Update docs/sources/operations/storage/logs-deletion.md

Co-authored-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* Update docs/sources/operations/storage/logs-deletion.md

Co-authored-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* Update docs/sources/operations/storage/logs-deletion.md

Co-authored-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>

* Specify all delete endpoints use authentication

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>

* Add description of delete modes

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>

* Apply suggestions from code review

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>

Co-authored-by: Christian Simon <simon@swine.de>
Co-authored-by: Sandeep Sukhani <sandeep.d.sukhani@gmail.com>
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
2022-05-16 12:17:11 +02:00
8838530976 Document /services API endpoint (#6111)
* Documented /services API endpoint

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>

* Grammar

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
2022-05-06 12:24:37 +02:00
0a68bd2d4e docs: update the labels timespan info (#6019)
* docs: update the labels timespan info

* updated docs

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>

* updated docs

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>

Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
2022-05-04 08:18:31 -07:00
149227b889 Minor fixes in docs/sources/api/_index.md (#5915) 2022-04-28 08:58:46 -07:00
d74fc2c06d Docs: update documentation about "limit" param (#5540) 2022-03-08 13:20:52 +01:00
6f46a8ffeb Docs: Fix links and formatting of HTTP API page (#5498) 2022-03-01 09:35:37 +01:00
c3edeac990 Docs: fix link reference to "Step vs Interval" section. (#5495) 2022-02-28 14:31:34 -08:00
ead9444d78 Document all support API timestamp formats. (#5439)
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
2022-02-28 17:47:48 +01:00
5f07e95fc8 Document query limit parameter default. (#5133) 2022-01-13 10:23:08 -05:00
191a8a6f9d Store metrics queueTime in seconds (#5052)
* Store metrics queueTime in seconds

* Address comments

* Helper function to convert seconds to nanoseconds
2022-01-06 13:46:58 +02:00
82f8f3c1e5 Log time in queue per request (#4949)
* Log time in queue per request

* Add querierID to log message

* Add unescape request url and tenant_ids to log message

* Add query enqueue time to metrics.go

* Remove "querier request dequeued" log from scheduler

* Address comments

* Rename enqueue_time to queue_time
* Store queue time in nanoseconds (int64)
* Use CanonicalMIMEHeaderKey for setting the httpgrpc header
2022-01-04 16:52:15 -05:00
98ecfefd89 Add distributor ring page (#4938)
* Implement new IngestionRateStrat Enum.

- This new IngestionRateStrat is used internally to represent the chosen
  ingestion rate strategy, to avoid using plain strings.

* Add a ring to the distributor.

As of now, the distributor only has a pointer to its lifecycler. Since
the ring HTTP handler isn't implemented for the lifecycler but it is
for the ruler, this extends the distributor by also holding a ring
instance.

* Implement /distributor/ring page.

* Reuse existing global strat const.

* Add distributor ring HTTP page tests.

* Add missing CHANGELOG entry.

* Document missing ring status pages.

* Fork Cortex util/http.go into source code.
2022-01-03 13:22:55 -05:00
35ebe967ea Docs: fix broken links (#4770)
* Docs: fix broken links

* Docs: fix another link name
2021-11-17 10:58:08 -08:00
3fef08ca1a 2.4 release notes, changelog, upgrade guide (#4658)
* update changelog, release notes, and upgrade guide for 2.4

* tweak release notes a little

* make path relative for kafka config

* update upgrade guide

* more docs
fix the cache size not applied to results cache.

* fix prefix name in ring_config
2021-11-05 16:21:29 -04:00
24accf6a5b Docs: correctly represent product name (#4416)
The product name is Grafana Loki.  The first use of the product name on
each web page should be the full product name.  After that, within each
page, it is fine to use just Loki.

This PR also set up some frontmatter with weights where it was missing
on a few files, and correct where "Loki" was not capitalized.
2021-10-06 00:21:47 +02:00
66b1d2c822 Reimplementing change from @jacobsakran (#4310)
I merged their change before the CLA was signed. We reverted that in #4299 and now I'm reopening

Signed-off-by: Danny Kopping <danny.kopping@grafana.com>
2021-09-10 12:14:52 +02:00
ede12d8435 Revert "Bug fixed in line 643 (#4298)" (#4299)
This reverts commit 598cad896e63543540d5d188fd58bea4b83aec76.
2021-09-09 18:21:44 +02:00
598cad896e Bug fixed in line 643 (#4298)
The command: curl -G -s "http://localhost:3100/api/prom/query" --data-urlencode '{foo="bar"}' | jq
gives the message: parse error: Invalid numeric literal at line 1, column 6
Instead, the command: curl -G -s  "http://localhost:3100/api/prom/query" --data-urlencode 'query={foo="bar"}' | jq, works
2021-09-09 17:43:54 +02:00
c9cdd44e13 Update _index.md (#4277) 2021-09-08 20:27:26 -04:00
11a0d28b61 Docs: first draft, Loki accepts out-of-order writes (#4237)
* Docs: first draft, Loki accepts out-of-order writes

* Update docs/sources/architecture/_index.md

Co-authored-by: Owen Diehl <ow.diehl@gmail.com>
2021-08-31 10:02:25 -04:00
e22e666ca4 fix: Restore /config endpoint and correct handlerFunc for buildinfo (#4027)
As far as I can tell from reading the "next" documentation, the
/loki/api/v1/status/buildinfo endpoint should return the build
information. The /version endpoint is also listed further down in the
documentation but from the code prior to this change, it looks like it
should perform the same function as buildinfo endpoint so I have
removed it.

I've updated the documentation to reflect my changes.

Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
2021-07-22 08:28:44 -04:00
af452047d3 Return build info under /loki/api/v1/status/buildinfo. (#3972)
* Return build info under `/version`.

Closes #3221

* Update documentation.

* Correct docs.

* Format version handler code.

* Ignore write error.

* Sort imports.

* Use `PrometheusVersion` struct.

* Set Go version.
2021-07-09 10:00:47 -04:00
7eceea082b Docs: Make identification of experimental items consistent and more obvious. (#3911) 2021-07-06 19:59:01 -04:00
0d27c21dd4 Doc updates: (#3823)
- Revise section titles
- Add weight metadata to specify ordering of subsections
- Remove TOC info from content prose, as it is already in the right side navigation panel
- Remove a redundant section about upgrading.
2021-06-09 09:04:10 +02:00
f6dcd3f3a4 Fix document links for api push example (#3690) 2021-05-18 07:44:33 -04:00
2a51fb42bf Distributor: Loki API can receive gzipped JSON (#3291)
* Push API recognize HTTP header "Content-Encoding: gzip" and upload gzipped JSON

* Fix documentation mistake
2021-02-05 10:21:53 -05:00
2afebbc064 Add config endpoint (#3228)
* Add config route

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>

* Add documentation

Signed-off-by: Michel Hollands <michel.hollands@grafana.com>
2021-01-26 05:05:37 -05:00