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

Loki HTTP/JSON Model Layer #1022

Merged
merged 59 commits into from
Sep 23, 2019
Merged

Conversation

joe-elliott
Copy link
Member

@joe-elliott joe-elliott commented Sep 16, 2019

What this PR does / why we need it:
This PR adds an http model layer between the internal protobuf components and json/http representations. This gives Loki the flexibility to support multiple json/http representations of internal objects. Ultimately this allows Loki to support the existing "legacy" protocol while also migrating forward to the prometheus compatible "v1" protocol.

v1 endpoints:

/loki/api/v1/query_range
/loki/api/v1/query
/loki/api/v1/label
/loki/api/v1/label/{name}/value
/loki/api/v1/tail

legacy endpoints:

/api/prom/query
/api/prom/label
/api/prom/label/{name}/values
/api/prom/tail

Response formats are documented in the tests.

Which issue(s) this PR fixes:
Fixes #273
It also partially addresses #1007

Special notes for your reviewer:
notes:

  • formats for all endpoints are documented and tested under pkg/logql/marshal and pkg/logql/marshal/legacy
  • old endpoints have been manually tested with logcli and grafana
  • logcli updated to use new model objects

Checklist

  • Documentation added
  • Tests updated

Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idiomatically I think the pkg/loghttp/v1 package should be just pkg/loghttp, you generally don't introduce a version path unless it's not version 1. (and when you do, the package name at pkg/loghttp/v2 would still be loghttp)

Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good! Sorry about all the nitpicky comments.

I don't know if you were planning on it already but I'd (personally) like for all the new exported functions to use valid godoc strings.

pkg/loghttp/legacy/marshal.go Outdated Show resolved Hide resolved
pkg/loghttp/legacy/marshal.go Outdated Show resolved Hide resolved
pkg/loghttp/legacy/marshal_test.go Outdated Show resolved Hide resolved
pkg/loghttp/legacy/marshal_test.go Outdated Show resolved Hide resolved
pkg/loghttp/legacy/query.go Outdated Show resolved Hide resolved
pkg/loghttp/v1/query.go Outdated Show resolved Hide resolved
pkg/querier/http.go Outdated Show resolved Hide resolved
@sh0rez
Copy link
Member

sh0rez commented Sep 18, 2019

CI builds are failing with undefined references, maybe check generated protos or so?

@joe-elliott
Copy link
Member Author

Editing the original comment to reflect the state of this PR.

pkg/querier/tail.go Outdated Show resolved Hide resolved
Copy link
Member

@rfratto rfratto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Although I may be a bit biased since I asked for a lot of changes. @cyriltovena could you take a second look?

@cyriltovena
Copy link
Contributor

I will I think Joe is not done ;)

Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
@joe-elliott
Copy link
Member Author

@cyriltovena @rfratto
I feel like this is complete. Removing WIP from title and updating Description.

@joe-elliott joe-elliott changed the title WIP: Loki HTTP/JSON Model Layer Loki HTTP/JSON Model Layer Sep 20, 2019
Signed-off-by: Joe Elliott <number101010@gmail.com>
d := q.resultsDirection()
i := iter.NewStreamsIterator(streams, d)
// sort and display entries
allEntries := make([]streamEntryPair, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good move, this wasn't really required as streams were already deduplicated by the querier.

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyriltovena cyriltovena merged commit 9614b02 into grafana:master Sep 23, 2019
rfratto added a commit to rfratto/loki that referenced this pull request Sep 23, 2019
/loki/api/v1/push was added in grafana#1010 but was temporarily reverted. grafana#1022
reintroduced changes from grafana#1010 but inadvertently did not reintroduce
the new push endpoint.
rfratto added a commit to rfratto/loki that referenced this pull request Sep 25, 2019
cyriltovena pushed a commit that referenced this pull request Sep 25, 2019
* docs: create structure of docs overhaul

This commit removes all old docs and lays out the table of contents and
framework for how the new documentation will be intended to be read.

* docs: add design docs back in

* docs: add community documentation

* docs: add LogQL docs

* docs: port existing operations documentation

* docs: add new placeholder file for promtail configuration docs

* docs: add TOC for operations/storage

* docs: add Loki API documentation

* docs: port troubleshooting document

* docs: add docker-driver documentation

* docs: link to configuration from main docker-driver document

* docs: update API for new paths

* docs: fix broken links in api.md and remove json marker from examples

* docs: incorporate api changes from #1009

* docs: port promtail documentation

* docs: add TOC to promtail configuration reference

* docs: fix promtail spelling errors

* docs: add loki configuration reference

* docs: add TOC to configuration

* docs: add loki configuration example

* docs: add Loki overview with brief explanation about each component

* docs: add comparisons document

* docs: add info on table manager and update storage/README.md

* docs: add getting started

* docs: incorporate config yaml changes from #755

* docs: fix typo in releases url for promtail

* docs: add installation instructions

* docs: add more configuration examples

* docs: add information on fluentd client

fluent-bit has been temporarily removed until the PR for it is merged.

* docs: PR review feedback

* docs: add architecture document

* docs: add missing information from old docs

* `localy` typo

Co-Authored-By: Ed Welch <ed@oqqer.com>

* docs: s/ran/run/g

* Typo

* Typo

* Tyop

* Typo

* docs: fixed typo

* docs: PR feedback

* docs: @cyriltovena PR feedback

* docs: add more details to promtail url config option

* docs: expand promtail's pipelines document with extra detail

* docs: remove reference to Stage interface in pipelines.md

* docs: fixed some spelling

* docs: clarify promtail configuration and scraping

* docs: attempt #2 at explaining promtail's usage of machine hostname

* docs: spelling fixes

* docs: add reference to promtail custom metrics and fix silly typo

* docs: cognizant -> aware

* docs: typo

* docs: typos

* docs: add which components expose which API endpoints in microservices mode

* docs: change ksonnet installation to tanka

* docs: address most @pracucci feedback

* docs: fix all spelling errors so reviewers don't have to keep finding them :)

* docs: incorporate changes to API endpoints made in #1022

* docs: add missing loki metrics

* docs: add missing promtail metrics

* docs: @pstribrany feedback

* docs: more @pracucci feedback

* docs: move metrics into a table

* docs: update push path references to /loki/api/v1/push

* docs: add detail to further explain limitations of monolithic mode

* docs: add alternative names to modes_of_operation diagram

* docs: add log ordering requirement

* docs: add procedure for updating docs with latest version

* docs: separate out stages documentation into one document per stage

* docs: list supported stores in storage documentation

* docs: add info on duplicate log lines in pipelines

* docs: add line_format as key feature to fluentd

* docs: hopefully final commit :)
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.

More browser / parser friendly return format for timestamps
4 participants