Read Nginx Logs with Promtail, Loki 1.9.x and Grafana 7

  Рет қаралды 29,845

SBCODE

SBCODE

Күн бұрын

Documentation : sbcode.net/grafana/nginx-prom...
Course Coupons : sbcode.net/coupons
This video is a continuation of my other videos where Loki and Promtail have already been set up and working on several hosts.
We will add to our Promtail scrape configs, the ability to read the Nginx access and error logs.
We need to add a new job_name to our existing Promtail config_promtail.yml
Restart the Promtail service and check its status.
If we look into the existing systemd-journal job that we already set up in the previous lessons, we will start to see some new errors concerning Promtail.
The promtail user, used by the Promtail service doesn't have the permissions to read the Nginx logs.
I will add the the promtail user to the user group adm so that it can read the log file.
If I go back into Grafana, I will see the new nginx job inside the Explore panel.
This is pretty good now, but we can make it better.
I want to be able to filter by the status code and other http properties.
We can do a regex in the log files as Promtail scans them and add labels to the matches.
For this we use pipeline_stages
Now I can create a dashboard for Nginx status codes.
0:00 Introducing reading Nginx log files with Promtail
0:40 Edit config-promtail.yml
1:10 Add Nginx scrape config
2:05 Additional label for host
3:30 Restart Promtail
3:50 Analyse Promtail permission errors
4:20 Edit Promtail user permissions and restart
5:10 Open Grafana and see new labels from Nginx
6:00 Discuss pipeline stages with regex
8:20 View new log labels from pipeline stages in Grafana
9:10 Analyse regex using regex101 website
11:00 Create a simple dashboard using the new Nginx log information
#grafana
#grafanaCourse
#grafanaTutorial

Пікірлер: 40
@taylormonacelli
@taylormonacelli 3 жыл бұрын
Gets right to the point without fluff nonsense talking. Quick and thorough. Thank you!
@FireBean8504
@FireBean8504 2 жыл бұрын
Again... these are the CLEANEST how-to's I've ever found.
@dannyluker7326
@dannyluker7326 3 жыл бұрын
Very helpful. Cleared up some ideas for me. Thank you.
@pneumaticdetach
@pneumaticdetach 3 жыл бұрын
This video was so helpful. Thank you!
@gustavokuno
@gustavokuno 5 ай бұрын
Great!
@ehsansasanian9653
@ehsansasanian9653 Жыл бұрын
That was a nice demonstration, tnx sir
@shinebayar
@shinebayar 3 жыл бұрын
This is so beautiful!! Straight to the point. Thank you.
@cmotruc
@cmotruc Жыл бұрын
Thank you! The video a bit outdated for 2023 but still helpful.
@sbcode
@sbcode Жыл бұрын
its not outdated for Promtail 1.9, Loki 1.9 and Grafana 7
@Naren061982
@Naren061982 2 жыл бұрын
Great stuff ...you saved my day
@MarcelLanz
@MarcelLanz 3 жыл бұрын
excellent video!
@imm2568
@imm2568 3 жыл бұрын
Nice sharing!
@narutokunn
@narutokunn 2 жыл бұрын
Superb. Thankyou
@seddikalaouiismaili
@seddikalaouiismaili 2 жыл бұрын
dou you have any example of template config for logfmt format ? thanks
@ammarrun2720
@ammarrun2720 3 жыл бұрын
Nice sharing, can we use alertmanager for loki sir?
@tablatronix
@tablatronix 3 жыл бұрын
Excellent video, I could not figure out the promtail docs at all, Is there some standard repo of templates for promtail, that is what I am having the hardest time with I assumed promtail would be able to parse some log formats out of the box, I am trying to read in my rsyslogs.
@sbcode
@sbcode 3 жыл бұрын
Promtail can read everything in the systemd-journal using the config on this page. sbcode.net/grafana/install-promtail-service/
@ericchua3492
@ericchua3492 2 жыл бұрын
One question. What if I am reading from tomcat catalina.out in here, the logs can different formats some will output info, debug with some sample xml output, etc unlike nginx access logs, it's quite standard will the regex way work ? thanks
@ajayshah6315
@ajayshah6315 2 жыл бұрын
Can Logs Panel in Grafana be used with a Sql datasource not Loki? Or the only way to make it work is through Loki
@klu41k
@klu41k Жыл бұрын
be careful with parsing the logs by labels it will create a new log stream for each of the labels which will really slow your Loki when you have real data
@besurrenderandneveryoursel6319
@besurrenderandneveryoursel6319 3 жыл бұрын
excuse me, i want to ask about grafana. can grafana monitoring website log, like someone trying to login in our website. if can, whats the requirements?, thanks.
@sbcode
@sbcode 3 жыл бұрын
If your website logs failed attempts somewhere, such as in a log file, or db, then you can point grafana to it.
@ajipyoga
@ajipyoga 2 жыл бұрын
how can i read nginx logs from many server, i have 3 server and want to centralized the nginx logs 1 server as main (there's grafana,loki, prometheus on it) and 3 servers as node/target
@sbcode
@sbcode 2 жыл бұрын
you con point multiple promtails to 1 loki. In each promtail config, add an extra label to indicate which host it is so then you can filter by individual host when needed. More info : sbcode.net/grafana/install-second-promtail/
@ajipyoga
@ajipyoga 2 жыл бұрын
@@sbcode thank you, i followed the steps and sucess, but i have one question, what does grpc_listen_port mean? if i want to add another server/target, should i set with different value of grpc_listen_port ?
@harshadsawant4519
@harshadsawant4519 2 жыл бұрын
entry_parser: raw is incorrect as entry_parser is deprecated
@sbcode
@sbcode 2 жыл бұрын
this video shows Promtail 1.9 and you can see that it works. See updated video at kzfaq.info/get/bejne/bMeGfsyX1dbZcaM.html which shows Promtail 2.4 with the pattern parser.
@rehan-pn6ed
@rehan-pn6ed 2 жыл бұрын
this is work for docker?
@sbcode
@sbcode 2 жыл бұрын
you can do this in docker if you want. I only show the manual may.
@rehan-pn6ed
@rehan-pn6ed 2 жыл бұрын
@@sbcode please make tutorial using docker, i cant connect the nginx with grafana
@sbcode
@sbcode 2 жыл бұрын
if docker is the problem, then maybe you need to understand more about docker, what it's doing, and why you are using it. If you knew what docker was doing, you'd know how to fix it.
@nishant4001
@nishant4001 Жыл бұрын
yes but make sure you shared the volume in promtail container for which you want the log
@user-uq1bm6jl8l
@user-uq1bm6jl8l 2 жыл бұрын
I'm trying to use | pattern ` - - " " "" ` but cant get any labels from it. In panels its just {} in legend Can't figure it out
@sbcode
@sbcode 2 жыл бұрын
I don't know. It maybe your version of loki.
@user-uq1bm6jl8l
@user-uq1bm6jl8l 2 жыл бұрын
@@sbcode Grafana 8.2.5 and Loki 2.4.1
@sbcode
@sbcode 2 жыл бұрын
your promtail user needs permissions to read the log file
@sbcode
@sbcode 2 жыл бұрын
i just tried {job="nginx"} | pattern ` - - " " "" ` and it worked. See my docs at sbcode.net/grafana/nginx-promtail/
@user-uq1bm6jl8l
@user-uq1bm6jl8l 2 жыл бұрын
​@@sbcode I figured out my mistake, now it works. Thank you very much!
ОБЯЗАТЕЛЬНО СОВЕРШАЙТЕ ДОБРО!❤❤❤
00:45
Grafana : Loki LogQL
18:03
SBCODE
Рет қаралды 25 М.
Grafana Loki: Like Prometheus, But for logs. - Tom Wilkie, Grafana Labs
36:42
CNCF [Cloud Native Computing Foundation]
Рет қаралды 69 М.
6 Easy Ways to Improve your Log Dashboards with Grafana and Loki
16:34
[ Kube 100 ] Getting started with Grafana Loki in Kubernetes
15:39
Just me and Opensource
Рет қаралды 48 М.
Log aggregation in Dotnet with Grafana and loki
13:51
Developing Woot
Рет қаралды 626
Apache vs NGINX
7:53
IBM Technology
Рет қаралды 275 М.