CentOS 7: Set up Centralized Logging with Rsyslog

Поделиться
HTML-код
  • Опубликовано: 21 окт 2024
  • In this video, I will be showing how to set up centralized logging with rsyslog service on CentOS 7 servers.
    This demonstration will be carried out on Virtual machines.
    I have also been doing videos on more modern technologies for logging like ELK stack and EFK stack. If you are interested, please watch the following playlist.
    • [ ElasticSearch 1 ] In...
    For any questions/issues/feedback, please leave me a comment and I will get back to you.
    Thanks for your time watching this video. If you liked it, please share it with your friends and don't forget to subscribe to my channel.
    Thanks,
    Venkat

Комментарии • 63

  • @patrickgosselin9756
    @patrickgosselin9756 8 лет назад +3

    Great video! Good production quality and right to the point. thanks!

    • @justmeandopensource
      @justmeandopensource  5 лет назад

      Hi Patrick Gosselin,
      Many thanks for watching this video. Hope you found it useful.
      Thanks,
      Venkat

  • @yfs9035
    @yfs9035 4 года назад +1

    Thanks, it's about time I set this up.

  • @Mac-ew1gv
    @Mac-ew1gv 6 лет назад +2

    Great work!!! I was stuck for about 2 hours trying to figure out why my switch could not contact my linux server.

  • @coreycox4802
    @coreycox4802 7 лет назад +2

    Great job explaining this

    • @justmeandopensource
      @justmeandopensource  5 лет назад +1

      Hi Corey Cox,
      Many thanks for watching this video. Hope you found it useful.
      Thanks,
      Venkat

  • @iammrchetan
    @iammrchetan 4 года назад

    That's great! Very easy & crisp, learnt this. Thanks!
    Although I've issue like, %HOSTNAME% creates directory name as localhost of remote server

  • @nadzeyahutsko1094
    @nadzeyahutsko1094 4 года назад +1

    It is so helpful! Thank you very much!!!

  • @SAlexandert8
    @SAlexandert8 7 лет назад +1

    Really made this easy, thanks!

    • @justmeandopensource
      @justmeandopensource  5 лет назад

      Hi Stephen Alexander,
      Many thanks for watching this video. Hope you found it useful.
      Thanks,
      Venkat

  • @Waris-bv7nu
    @Waris-bv7nu 6 лет назад +1

    Great video. Thanks for sharing.

  • @georgesmiley3334
    @georgesmiley3334 6 лет назад +1

    Thank you for this nice video. I tried to follow this to configure my own rsyslog file. However, my template won't create a new remotehosts directory for me. Did you do many other configure for the rsyslog.conf file? What is the unmask for your rsyslog.conf file?

    • @justmeandopensource
      @justmeandopensource  6 лет назад

      Umask doesn't matter. Are you sure you followed the video and rsyslog.conf configuration line by line. Please give it another try from "5:30".
      If you couldn't see the configuration clearly, it is the below three lines that you need to add to rsyslog.conf and don't forget to restart the rsyslogd service.
      $template RemoteLogsTesting,"/var/log/remotehosts/%HOSTNAME%/%now%.log"
      if $fromhost-ip != '127.0.0.1' then -?RemoteLogsTesting
      & stop
      Thanks

  • @lanhnguyenthi1205
    @lanhnguyenthi1205 Год назад

    I followed your steps, restared rsyslogd service after configured. Both servers can ping to gether but the log is still written into `var/log/messages`.
    Do you know the reason? Do we need to set Selinux to Permisive mode?

  • @thelebbies
    @thelebbies 7 лет назад +2

    This was fantastic man!!

    • @justmeandopensource
      @justmeandopensource  5 лет назад +1

      Hi Sahr Lebbie,
      Many thanks for watching this video. Hope you found it useful.
      Thanks,
      Venkat

  • @priyasudhirpriya
    @priyasudhirpriya 3 года назад +1

    Hi Venkat, I did the exact configuration but logs are not displayed on the server. logs are not recorded in the server. Any idea? Thanks for your video. It gave me an idea of how central logs work.
    Thank you.

    • @justmeandopensource
      @justmeandopensource  3 года назад +2

      Hi Sudhir, thanks for watching. I did this video more than 5 years ago. I am glad that it is still relevant. I need to revisit this to be able to help you. Let me see if I can get some time for this.

    • @priyasudhirpriya
      @priyasudhirpriya 3 года назад

      @@justmeandopensource thank you very much Venkat.

  • @hamzadev8311
    @hamzadev8311 4 года назад +1

    Thank you man , very interesting (y)

  • @santhosh933
    @santhosh933 7 лет назад +2

    God bless you...

    • @justmeandopensource
      @justmeandopensource  5 лет назад

      Hi Santhosh S T,
      Many thanks for watching this video. Hope you found it useful.
      Thanks,
      Venkat

  • @b_h_a_v_i_k
    @b_h_a_v_i_k 6 лет назад +1

    Hi, Thank you for the video. I am facing an issue though.
    My configuration is not creating the remotehosts directory and continues to write to var/log/messages
    Do you know what can be the issue?

    • @justmeandopensource
      @justmeandopensource  6 лет назад +3

      After following my video from "5:30", did you restart rsyslogd service?
      The configuration you need to add as mentioned in the video is
      $template RemoteLogsTesting,"/var/log/remotehosts/%HOSTNAME%/%now%.log"
      if $fromhost-ip != '127.0.0.1' then -?RemoteLogsTesting
      & stop
      Thanks

  • @SonnetGomes
    @SonnetGomes 7 лет назад

    Thank you so much for this tutorial. It's great to be able to use a log server to aggregate all the logs. But would it be possible to access the local logs if Network or the log server was down (or overwhelmed by 1000s of server logs)? Is it possible to scale or have any redundant log server?

    • @justmeandopensource
      @justmeandopensource  6 лет назад

      Hi Sonnet,
      Thats definitely possible. I just read an article from RedHat knowledge Base.
      IMPORTANT: Only works if you configure TCP (reliable guaranteed delivery of packets) forwarding with "@@" and not UDP (not reliable protocol)
      Configure two central log servers in the client's /etc/rsyslog.conf as below
      *.* @@central-log-1
      $ActionExecOnlyWhenPreviousIsSuspended on
      &@@central-log-2
      This will forward logs to central-log-1 server and if it can't be reached or it is powered down, the logs will be forwarded to central-log-2.
      IMPORTANT: On both the central log servers, where you collect clients logs (for eg: /var/log/remotehosts), it has to be NFS and mounted readwrite on both the central log servers. Otherwise if you use local filesystem then you will end up having log files in two places.
      Hope this makes sense
      Thanks

  • @georgeradu3759
    @georgeradu3759 4 года назад +1

    great work,man

  • @JoseBarbosa-gv2mr
    @JoseBarbosa-gv2mr 6 лет назад

    This is an awesome video and it's working for me....however, I'd like to know if it at all possible to have the files merged together, when I'm trying to look at the big picture? Thanks in advance.

    • @justmeandopensource
      @justmeandopensource  6 лет назад

      Hi Jose, I guess you mean, on the server side you wanted all the clients to write to a single file instead of one per machine.
      You can do that. In the video at "5:45" I demonstrated how to configure rsyslog.conf to allow clients to log into separate file under /var/log/remotehosts//.log
      If you want all clients to write to same file, then just use the below line
      $template RemoteLogsTesting,"/var/log/remotehosts/allclients.log"
      And follow rest of my video.
      The more ideal way would be to use Splunk for these. If your organization has Splunk server, you can install Splunk Forwarder on each client or just on the centralized log server and forward logs to Splunk Server. In this case you can look at the bigger picture. Splunk is vast and apt for logging,searching,visualizing.
      Hope this was useful.
      Thanks.

  • @panneerselvam3785
    @panneerselvam3785 6 лет назад

    Great tutorial Venkat. Do you have any reference to config rsyslog for application log files???

    • @justmeandopensource
      @justmeandopensource  6 лет назад

      Hi Panneer,
      You can do that. But its not straight forward. For example, if you wanted to forward Apache logs to a central log server via rsyslog forwarding, you will have to do something like below.
      Configure Apache to log using rsyslog.
      Have a look at below documentation on how to use the "pipe" argument on CustomLog directive
      httpd.apache.org/docs/current/mod/mod_log_config.html#customlog
      For eg;
      CustomLog "|/usr/bin/logger -t apache -p local6.info" combined
      ErrorLog "|/usr/bin/logger -t apache -p local6.err"
      That should be it. Apache after restart, should start logging to syslog facility and rsyslog will forward to centralzed log server.
      Hope this gives you some direction to explore further.
      Thanks.

  • @TheNielsAlmelo
    @TheNielsAlmelo 5 лет назад +1

    can i also log windows machines to my centOS Rsyslog?

    • @justmeandopensource
      @justmeandopensource  5 лет назад +1

      Hi, thanks for watching this video. I believe its possible but not out of the box. You have to install some third party softwares for that.
      Check the below blog post which looks promising with datagram-syslog agent.
      yallalabs.com/windows/how-to-forward-windows-system-event-logs-to-a-linux-syslog-server/
      There are also other softwares that can do the same thing. But I haven't tried any of them.
      Cheers.

  • @bodhisattwaghosh2673
    @bodhisattwaghosh2673 8 лет назад +1

    Very Good One.

    • @justmeandopensource
      @justmeandopensource  5 лет назад

      Hi Bodhisattwa Ghosh,
      Many thanks for watching this video. Hope you found it useful.
      Thanks,
      Venkat

  • @faizi80
    @faizi80 7 лет назад

    Do you know if it is possible to just "copy" already created log files instead of online logging on remote server. I mean, copy the files to remote server when logrotate happens ?

    • @justmeandopensource
      @justmeandopensource  6 лет назад

      Hi Muhammad, the idea of centralized logging is to allow a system (client) to forward its logs **realtime** to a centralized server. This is useful since you can have one stop shop for all your client logs instead of logging into each of them. Not just that, it is also useful when security of client machine is compromised and intruder gets hold of the system. The intruder can do whatever he wants and manipulate the log files to make you believe that nothing happened. If you had centralized logging enabled, it is always recorded. Also you can control logrotation for all clients in one place on the centralized server.
      Given all these usecases, I don't understand why you want to copy rotated log files to another server. May be you wanted to backup and retain those logs. You can do that via a cron job on the client that rsyncs the pattern matching log files to a remote server.
      Hope this makes sense.
      Thanks

  • @aronb.acostagarcia9784
    @aronb.acostagarcia9784 5 лет назад +1

    Nice video! qq how can I configure this to remove all logs older than one week?

    • @justmeandopensource
      @justmeandopensource  5 лет назад +1

      Hi Aron, thanks for watching this video. As per the setup shown in this video, you will see one directory per client machine in /var/log/remotehosts directory. Under each of those directory you will see log files per day.
      You can configure log rotation to do what you want. You can create a config file under /etc/logrotate.d directory.
      Thanks

    • @aronb.acostagarcia9784
      @aronb.acostagarcia9784 5 лет назад +1

      @@justmeandopensource Thanks for your responce, I am trying with this but not works,
      vi /etc/logrotate.conf
      /var/log/remotehosts/* {
      ifempty
      size 0
      postrotate
      /usr/bin/find /var/log/remotehosts/ -name "*.log.*" -type f -mtime +7 -exec rm -f {} \;
      endscript
      }
      Could you please provide the commands to do that?
      Thanks a lot!!

    • @justmeandopensource
      @justmeandopensource  5 лет назад

      @@aronb.acostagarcia9784 just noticed in you postrotate block, in your find command you have "*.log.*" which won't match anything. Try changing that to "*.log".
      But there are other elegant ways without using the hacked way of using postrotate block. That block is to do something when the log has been rotated.

  • @Pingao2012
    @Pingao2012 2 года назад

    Nice!

  • @brainio1762
    @brainio1762 8 лет назад +1

    Great tutorial :-)

    • @justmeandopensource
      @justmeandopensource  5 лет назад

      Hi Brain I/O,
      Many thanks for watching this video. Hope you found it useful.
      Thanks,
      Venkat

  • @erickwakye4491
    @erickwakye4491 5 лет назад +1

    Hi how do u push windows servers or cisco logs to rsyslog a video could help please

    • @justmeandopensource
      @justmeandopensource  5 лет назад +1

      Hi Eric, Thanks for watching my video. I wasn't sure whether we could forward Windows event logs to a Linux rsyslog server. But when I searched, I found the below serverfault link where someone already asked the same question. And there seems to exist few options.
      I have got many videos in the pipeline that I need to work on. And if I get some time, I will check this and if something seems to be working, I will definitely make a video of it.
      Thanks,
      Venkat

    • @erickwakye4491
      @erickwakye4491 5 лет назад +1

      @@justmeandopensource i appreciate your response, also doing checks if i get something on it i would push the link to you. You know centralized log system is a big thing now so it would really help if rsyslog could very flexible with other operating systems or devices such as windows, CISCO, and others to push logs.

    • @justmeandopensource
      @justmeandopensource  5 лет назад +1

      Hi Eric,
      I don't think I pasted the link in my previous comment. Here it is.
      serverfault.com/questions/422800/forward-windows-events-logs-to-rsyslog/427036
      Yes Centralized Logging is a big thing now a days. Just wondering whether you thought about Splunk or Elastic Search which are widely used. ELK stack especially is a good one. You can install an agent and forward logs/metrics from any device/OS.
      I did a video on ELK stack recently. If you are interested, you can check it out at ruclips.net/video/Cfbanio3Lao/видео.html and see if thats helpful.
      Thanks,
      Venkat

    • @erickwakye4491
      @erickwakye4491 5 лет назад +2

      @@justmeandopensource okay sir, will check and revert

  • @flavioreis9280
    @flavioreis9280 4 года назад

    Thank you for your video! o/

  • @aaammm1888
    @aaammm1888 4 года назад +1

    can this be config to send log to my remote tor server?

    • @justmeandopensource
      @justmeandopensource  4 года назад +1

      Hi, thanks for watching this video. You want the logs to be sent to a tor server? Is that a syslog service? Or do you want your tor server logs to be forwarded to a central syslog server?

    • @aaammm1888
      @aaammm1888 4 года назад +1

      @@justmeandopensource Hi thanks for the reply first thing first what a great video you made thanks
      well Im looking into security/hardening my centos servers I will have a few each server running different thing like one will be running nginx and php one will be running mysql so on i would like to make a central logserver where all my other servers will send logs to this server so i can monitor all log from one server but this server will be hidden within tor so the central server will be hosted on tor

    • @justmeandopensource
      @justmeandopensource  4 года назад +1

      @@aaammm1888 If your client machines can talk to the central log server in a consistent way, then there shouldn't be any problem. What is the exact issue you are facing? Is your central log server not accessible? Is its IP constantly changing?

  • @faizi80
    @faizi80 7 лет назад +1

    Good short tutorail, It could have been better if you had used server/client words instead of cenvm01 02, it kind of confuses.

    • @justmeandopensource
      @justmeandopensource  6 лет назад

      Yeah that makes sense. I should have thought about it from viewers point of view. Thanks for your feedback and I will make sure I use appropriate conventions for naming.