By Dan Ambrose
Published 17th April 2023
Sending your Northflank logs to Grafana Cloud or any self-hosted Loki instance is simple. This guide will take you through the steps to integrate your Loki instance with Northflank.
This guide is targeted at Grafana Cloud, but you can add a self-hosted instance of Loki by following similar steps. Specific considerations for self-hosted instances are noted at the end of the guide.
If you haven’t already, you’ll need to create your Grafana Cloud Stack in your Grafana Cloud dashboard.
The region can’t be changed once created. If possible, you should consider which region your Northflank workloads are running in and try to co-locate your Grafana Cloud Stack to reduce latency.
You need to create an access policy for Northflank to be able to write logs to Grafana Cloud. Close the stack creation window and navigate to Access Policies under the security menu.
Create a new access policy and give it the logs write
scope only.
After you have created the access policy, add a new token and save it somewhere secure.
To add the log sink to Northflank, you need to get the URL and username for the Grafana Data Source.
On the Grafana Stack dashboard, click Details
on the Loki card and note your URL and username, you will need these in the next step.
Follow this link or navigate to the log sinks page in your team or user account settings and add a log sink.
Enter a recognisable name for the sink and select Loki
as the sink type.
Fill in the fields with your corresponding information from Grafana Cloud, enter the URL and user from your Loki instance details. The password is your access policy token that you generated earlier.
You can target specific projects to forward logs from, and only containers running in the selected projects will have their logs forwarded, or leave this deselected to forward all logs from your account.
You can additionally forward logs from a linked CDN (like Fastly) or network mesh logs.
Before your log sink is created Northflank tries to send a log line to your Loki instance to verify the credentials are correct. This appears as a log line consisting of validating log sink credentials
.
Go back to your cloud stack dashboard and click Launch on Grafana
.
Then click the Explore
compass from the sidebar and select Loki as your data source to query using the dropdown.
Using the Query Builder, you should see the host
label with value Northflank
.
Logs from Northflank are labelled to help identify where log events come from so you can create queries and alerts for your Northflank hosted workloads.
A simple way to view all your logs from Northflank is to create a query with Host = “Northflank”
.
To find out more about the Loki Query Logs, look at the LogQL docs.
Setting up your self hosted Loki is straightforward. Make sure your Loki instance is publicly exposed and then create your log sink with your Loki endpoint.
By default, Loki doesn’t come with any native authentication for incoming HTTP requests. Northflank supports Basic HTTP authentication and will add your credentials to the request headers. This is left optional but is recommended.
If you want to modify your sink after creation, navigate to the log sink list and click on the sink to view its details.
You can update the project targets and sink data as well as pause/resume the sink.
Have questions or feedback? You can always reach out to our team.