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

feat: Loki Log Streaming #1385

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Conversation

amanji
Copy link
Contributor

@amanji amanji commented Oct 9, 2024

No description provided.

@amanji amanji requested review from loneil and esune October 9, 2024 15:21
@amanji amanji linked an issue Oct 9, 2024 that may be closed by this pull request
amanji added 10 commits October 10, 2024 16:54
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
@loneil loneil force-pushed the bcgov/feature/loki-log-streaming branch from 227c6a2 to 592789b Compare October 10, 2024 23:59
@loneil
Copy link
Contributor

loneil commented Oct 10, 2024

Rebased and resolved package conflicts

@amanji amanji marked this pull request as ready for review October 11, 2024 21:33
@loneil
Copy link
Contributor

loneil commented Oct 15, 2024

@amanji there's a pull request here that refactors some startup to a manage script. Any thoughts on if we merge that if that would cause any issues (or should have change to include) the docker compose startup instructions in this PR?

https://github.com/bcgov/traction/pull/1388/files

@amanji
Copy link
Contributor Author

amanji commented Oct 15, 2024

Let's give it a try. I doubt there will be a huge impact

@amanji
Copy link
Contributor Author

amanji commented Oct 15, 2024

@loneil we'd need to add this to the manage script:

docker compose -f docker-compose.logs.yml -f docker-compose.yml up

@amanji amanji force-pushed the bcgov/feature/loki-log-streaming branch from bea4259 to c8e0a77 Compare October 16, 2024 14:40
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
@amanji amanji force-pushed the bcgov/feature/loki-log-streaming branch from c8e0a77 to 48818a4 Compare October 16, 2024 14:47
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Comment on lines +137 to +139
- SERVER_LOKI_URL=${SERVER_LOKI_URL}
- FRONTEND_TENANT_PROXY_URL=${FRONTEND_TENANT_PROXY_URL}
- FRONTEND_LOG_STREAM_URL=${FRONTEND_LOG_STREAM_URL}
Copy link
Member

Choose a reason for hiding this comment

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

These envvars need to be added to the chart as well

Copy link
Contributor Author

@amanji amanji Oct 22, 2024

Choose a reason for hiding this comment

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

See chart if its correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@esune can you confirm if the included chart changes look correct for these variables?

Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
Signed-off-by: Akiff Manji <akiff.manji@quartech.com>
@amanji amanji requested a review from esune October 22, 2024 14:25
@amanji
Copy link
Contributor Author

amanji commented Oct 22, 2024

FYI trying on the deployed PR and hitting start on the logs doesn't seem to show output or an error
See an aggregateError in the tenant UI backend logs: image

We need to build in three more services for the logging. I'm assuming the deployed services dont account for those yet

@i5okie do you have any suggestiono n how to set things up for the supporting services? i.e.: we list them as pre-requisites or do we include (optional) depenedncies in the Helm chart?

In my opinion, I think Traction should work without throwing exceptions or failing when it runs without Loki backend being configured. As such, I think Loki should be an optional component setup separately by the user. I'd imagine, if loki endpoint is not provided/log-streaming is disabled, the feature should be turned off in someway. Or at least say logs unavailable in a friendly (not app crashing) manner on the page.

As for the promtail, it should be included as an optional sidecar. We could put together documentation, with example configs on how to set Traction up with Loki. I can help with the latter two.

I'll update the PR to hide the log feature when the FRONTEND_LOG_STREAM_URL is not set.

Copy link

github-actions bot commented Dec 7, 2024

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Dec 7, 2024
@esune esune removed the Stale label Dec 12, 2024
@esune
Copy link
Member

esune commented Dec 12, 2024

I'll update the PR to hide the log feature when the FRONTEND_LOG_STREAM_URL is not set.

@amanji it does not look like changes have been pushed since this - can you confirm? Would you be able to push the above tweak so we can move forward with reviewing/merging the pr?

Signed-off-by: Akiff Manji <amanji@petridish.dev>
@amanji
Copy link
Contributor Author

amanji commented Jan 10, 2025

@esune @i5okie @loneil Please take a look at this again. The frontend has been updated to filter out the Log component/routes from display if the logStreamUrl is not configured.

amanji and others added 2 commits January 10, 2025 08:13
Signed-off-by: Akiff Manji <amanji@petridish.dev>
Signed-off-by: Lucas ONeil <lucasoneil@gmail.com>
@loneil
Copy link
Contributor

loneil commented Jan 10, 2025

Getting a fail on one of the loki fields during Helm deployment

Error: template: traction/templates/ui/deployment.yaml:9:24: executing "traction/templates/ui/deployment.yaml" at <include (print $.Template.BasePath "/ui/configmap.yaml") .>: error calling include: template: traction/templates/ui/configmap.yaml:33:29: executing "traction/templates/ui/configmap.yaml" at <include "loki.fullname" .>: error calling include: template: no template "loki.fullname" associated with template "gotpl"

Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

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

A couple minor tweaks, looks good otherwise.

@@ -29,6 +30,7 @@ data:
SERVER_SMTP_SECURE: {{ .Values.ui.smtp.secure | quote }}
SERVER_SMTP_USER: {{ .Values.ui.smtp.user | quote }}
SERVER_TRACTION_URL: http://{{ include "tenant_proxy.fullname" . }}:{{ .Values.tenant_proxy.service.port }}
SERVER_LOKI_URL: http://{{ include "loki.fullname" . }}:{{ .Values.loki.service.port }}
Copy link
Member

Choose a reason for hiding this comment

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

loki.fullname will not be available unless Loki is deployed at the same time as Traction.
I think it might be best to just use a full URL from the values file in case Loki is not being deployed with the solution. Otherwise you'll have to add Loki as a dependent chart to Traction and handle on/off scenarios.

Comment on lines 594 to 605
## @section Loki configuration
##
loki:
## Loki service configuration
##
service:
## @param loki.service.type Kubernetes Service type
##
type: ClusterIP
## @param loki.service.port Port to expose for http services
port: 3100

Copy link
Member

Choose a reason for hiding this comment

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

If we go with a "hard-coded" Loki url this should be able to go.

@loneil
Copy link
Contributor

loneil commented Jan 10, 2025

Getting a local docker error as well for me on fresh setuo
Error response from daemon: error looking up logging plugin loki: plugin "loki" not found

Built fresh (docker compose build) and then any of
docker compose -f docker-compose.logs.yml -f docker-compose.yml up
docker compose up
./manage start

If I install the loki plugin
docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
it starts up

I guess we could add the plugin install to the manage script?
That makes starting up need the manage script, and installs a plugin on people's systems even if they're not using the logging feature.

Want to support people starting up without needing logging setup so I'm not sure if there's a way to make that plugin more optional?

Signed-off-by: Lucas ONeil <lucasoneil@gmail.com>
Signed-off-by: Lucas ONeil <lucasoneil@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

Log consumption for tenants
4 participants