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

Targets: Add Heroku HTTPS drain target #6448

Merged
merged 25 commits into from
Jul 15, 2022

Conversation

thepalbi
Copy link
Contributor

What this PR does / why we need it:
Heroku streams logs from all its service layers (systems, builds, application) to a common component called LogPlex, from which they can be consumed. In the Heroku platform itself, the ways for consuming logs are either via CLI, which offers basic filtering and tail capabilities; or in their web UI.

Apart from both of these, LogPlex has a concept of drains, which are destinations where logs can be streamed to, and shipped, consumed, etc. Between these, once exposes a mechanism for shipping to a HTTPS destination. This is called HTTPS Drain.

This PR adds a new promtail target that exposes an HTTP server (in the form of a drain as described above), that can be used to receive logs from Heroku.

The target allows the following configurations:

  heroku_drain:
    server:
      http_listen_address: 0.0.0.0
      http_listen_port: 8080
      log_level: debug
      register_instrumentation: true
    labels: 
      job: heroku_logs_test
    use_incoming_timestamp: true

This target exposes some of the received "label" as "internal labels" to be re-labeled by the user using the scrape config (much like the syslog target does), and dropped if not used. These are:

  • __logplex_host: hostname of the log producer
  • __logplex_app: application name of the log producer
  • __logplex_proc: process id of the log producer
  • __logplex_log_id: log identifier

On the other hand, Heroku offers best-effort delivery guarantees. That said, this target implementation does not offer no other guarantees. In case that some delivery from Heroku to promtail fails, this will be dropped and eventually Heroku will notify this receiver that some log entries were dropped.

Which issue(s) this PR fixes:
n/a

Special notes for your reviewer:
Since Heroku ships their metrics through HTTP, in a syslog formatted message with octet framing (just like promtail's syslog target expects) this new target is very similar to both the loki-push and syslog targets.

Also, in the Heroku HTTPS drain docs, a mention is made that the syslog format that Heroku uses is not RFC-compliant. Because of that, an utils Go lib that the same company has publicly available is used for parsing each entry.

Checklist

  • 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

@thepalbi thepalbi requested a review from a team as a code owner June 21, 2022 17:22
@CLAassistant
Copy link

CLAassistant commented Jun 21, 2022

CLA assistant check
All committers have signed the CLA.

@thepalbi
Copy link
Contributor Author

Happy to add docs, don't know in which specific section to do so

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

This looks great @thepalbi, thanks for the contribution!

The docs can be added in these sections:
https://grafana.com/docs/loki/latest/clients/promtail/configuration/#scrape_configs and https://grafana.com/docs/loki/latest/clients/promtail/scraping/

which is defined here docs/sources/clients/promtail/configuration.md and docs/sources/clients/promtail/scraping.md respectively.

I've added a couple nits but overall this looks solid.

I think we'll need to get the terminology consistent here as well, for clarity. We're referring to "heroku", "heroku target", "heroku drain" in a few places... it'd be great if we could standardise on "heroku drain", or whatever @KMiller-Grafana would suggest.

thepalbi and others added 2 commits June 29, 2022 16:16
Co-authored-by: Danny Kopping <dannykopping@gmail.com>
Co-authored-by: Danny Kopping <dannykopping@gmail.com>
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0.4%
+               loki	0%

@thepalbi
Copy link
Contributor Author

thepalbi commented Jun 29, 2022

I think we'll need to get the terminology consistent here as well, for clarity. We're referring to "heroku", "heroku target", "heroku drain" in a few places... it'd be great if we could standardise on "heroku drain", or whatever @KMiller-Grafana would suggest.

Completely agree, I'll do a cleanup pass making the naming consistent with "heroku drain" since it's the de-facto naming for this mechanism for moving heroku logs

In some places I'll compose the naming like: heroku_drain_targer_* to keep naming consistent with other targets.

Also, modifying internal labels produced by the target to:

		lb.Set("__heroku_drain_host", message.Hostname)
		lb.Set("__heroku_drain_app", message.Application)
		lb.Set("__heroku_drain_proc", message.Process)
		lb.Set("__heroku_drain_log_id", message.ID)

to keep those names consistent with the target.

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@dannykopping
Copy link
Contributor

Thanks for the changes @thepalbi! This is almost ready for approval; can you please address the last couple comments? I'll then re-review

@thepalbi
Copy link
Contributor Author

@dannykopping sure thing Danny! Should I address the documentation in a follow up PR?

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0.3%
+            querier	0%
+ querier/queryrange	0.1%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@dannykopping
Copy link
Contributor

dannykopping commented Jul 4, 2022

@dannykopping sure thing Danny! Should I address the documentation in a follow up PR?

If you could include it in this one, I think that'd be preferable. Thanks! 🙏
Ah I see you've already created #6560 - no biggie 👍

@thepalbi
Copy link
Contributor Author

thepalbi commented Jul 4, 2022

@dannykopping added docs in this PR as discussed!

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
- querier/queryrange	-0.1%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

Approving the code 👍 great work @thepalbi!

@KMiller-Grafana will review the docs, and then we can merge

@KMiller-Grafana KMiller-Grafana added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Jul 13, 2022
Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

I've made lots of small suggestions to improve the capitalization and grammar. Thanks for the thorough documentation.

thepalbi and others added 9 commits July 14, 2022 11:21
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
Co-authored-by: Karen Miller <84039272+KMiller-Grafana@users.noreply.github.com>
@thepalbi
Copy link
Contributor Author

@KMiller-Grafana just applied all your suggestions, and removed something that I copied erroneously form Promtail's GCP docs

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

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

Docs look good to me. Thank you for the changes.

@dannykopping dannykopping merged commit 0e28452 into grafana:main Jul 15, 2022
lxwzy pushed a commit to lxwzy/loki that referenced this pull request Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants