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

logcli: add --proxy-url flag for http/https proxy support #6484

Merged
merged 1 commit into from
Jun 24, 2022

Conversation

joemiller
Copy link
Contributor

@joemiller joemiller commented Jun 23, 2022

Add --proxy-url flag to logcli to support connecting to Loki instances running behind either HTTP or HTTPS CONNECT-style proxies.

Examples:

http proxy:

logcli \
  --addr="http://loki-distributed-querier.loki.svc.cluster.local.:3100/" \
  --proxy-url "http://envoy.dom.tld" \
  query '{app="foo"}'

https proxy with mTLS auth:

logcli \
  --addr="https://loki-distributed-querier.loki.svc.cluster.local.:3100/" \
  --proxy-url "https://envoy.dom.tld" \
  --cert tls.crt \
  --key tls.key \
  --ca-cert ca.crt \
  query '{app="foo"}'

Note that tail (-f) support and https proxies only work with a fork of the gorilla/websocket lib. There are open PRs that promise to add support for https proxies such as: gorilla/websocket#740

Add the following to go.mod to use the fork with https support:

replace github.com/gorilla/websocket v1.4.2 => github.com/philipatl/websocket v1.4.3-0.20211206152948-d16969baa130

I am maintaining a separate branch that includes the vendor'd fork here: https://github.com/planetscale/loki/tree/proxy-support

What this PR does / why we need it:

This PR makes it possible to connect logcli to Loki instances behind forward/CONNECT http and https proxies. This is already supported by other tools in this repo such as promtail via its proxy_url config flag.

Special notes for your reviewer:

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

Add `--proxy-url` flag to `logcli` to support connecting to Loki
instances running behind either HTTP or HTTPS CONNECT-style proxies.

Examples:

http proxy:

```
logcli \
  --addr="http://loki-distributed-querier.loki.svc.cluster.local.:3100/" \
  --proxy-url "http://envoy.dom.tld" \
  query '{app"foo"}'
```

https proxy with mTLS auth:
```
logcli \
  --addr="https://loki-distributed-querier.loki.svc.cluster.local.:3100/" \
  --proxy-url "https://envoy.dom.tld" \
  --cert tls.crt \
  --key tls.key \
  --ca-cert ca.crt \
  query '{app"foo"}'
```

Note that tail (`-f`) support and https proxies only works with a fork of the
`gorilla/websocket` lib. There are open PRs that promise to add support
for https proxies such as: gorilla/websocket#740

Add the following to `go.mod` to use the fork with https support:

```
replace github.com/gorilla/websocket v1.4.2 => github.com/philipatl/websocket v1.4.3-0.20211206152948-d16969baa130
```
@joemiller joemiller requested a review from a team as a code owner June 23, 2022 16:44
@CLAassistant
Copy link

CLAassistant commented Jun 23, 2022

CLA assistant check
All committers have signed the CLA.

@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.

Thanks for the contribution @joemiller 🙌 this is great
Do you mind opening a separate issue for the tail functionality pls?

@joemiller
Copy link
Contributor Author

@dannykopping opened #6499 tnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants