Install Promtail Binary and Start as a Service
Video Lecture
Download and Install Promtail Binary
Now we will create the Promtail service that will act as the collector for Loki.
We can also get the Promtail binary from the same place as Loki.
To check the latest version of Promtail, visit the Loki releases page. https://github.com/grafana/loki/releases/
# |
|
# |
|
# |
|
And allow the execute
permission on the Promtail binary
# |
|
Create the Promtail config
Download the Promtail config that matches the version.
# |
|
Configure Promtail as a Service
Now we will configure Promtail as a service so that we can keep it running in the background.
Create user specifically for the Promtail service
# |
|
Create a file called promtail.service
# |
|
And add this script,
1 2 3 4 5 6 7 8 9 10 11 |
|
Now start and check the service is running.
# # # |
|
We can now leave the new Promtail service running.
Now, since this example uses Promtail to read system log files, the promtail
user won't yet have permissions to read them.
So add the user promtail
to the adm
group
# |
|
Verify that the user is now in the adm
group
# |
|
Restart Promtail and check status
# # |
|
If you ever need to stop the new Promtail service, then type
# # |
|
Note it may take a minute to stop.
Troubleshooting
Permission Denied
msg="error creating promtail" error="open /tmp/positions.yaml: permission denied"
You should check the owner of the file configured in the positions
section of the promtail-local-config.yaml
matches the name of the user configured in the promtail.service
script above.
My user is promtail
, and the positions
is set as /tmp/positions.yaml
, so I set the owner.
# |
|
If you set up Promtail service with to run as a specific user, and you are using Promtail to view adm
and you don't see any data in Grafana, but you can see the job name, then possibly you need to add the user Promtail to the adm
group.
# |
|
You may need to restart the Promtail service and checking again its status.
Spaces versus Tabs
If you see the error found character that cannot start any token
than that is likely to mean you have a tab somewhere in the YAML indenting one of the tokens. Replace it with spaces.
Tail Promtail
On Linux, you can check the syslog
for any Promtail related entries by using the command,
# |
|
Daemons using outdated libraries
Since Ubuntu 22.04, installing new packages may give you a full screen prompt to restart other dependent services. Press Tab to highlight the OK
option, and press Enter.
Log Browser renamed to Label browser
The Log browser
has now been renamed to the [Label browser
], and it is a button that opens a modal window.