Skip to main content
Sumo Logic

Collect Varnish Logs and Metrics for Non-Kubernetes environments

We use the Telegraf operator for Varnish metric collection and Sumo Logic Installed Collector for collecting Varnish logs. The diagram below illustrates the components of the Varnish collection in a non-Kubernetes environment. Telegraf runs on the same system as Varnish, and uses the Varnish input plugin to obtain Varnish metrics, and the Sumo Logic output plugin to send the metrics to Sumo Logic. Logs from Varnish on the other hand are sent to a Sumo Logic Local File source.

clipboard_e5bd58c8c8ed512ab2598dcecd523cdad.png

This section provides instructions for configuring metrics collection for the Sumo Logic App for Varnish. Follow the below instructions to set up the metric collection:

  1. Configure Metrics Collection

    1. Configure a Hosted Collector

    2. Configure an HTTP Logs and Metrics Source

    3. Install Telegraf

    4. Configure and start Telegraf

  2. Configure Logs Collection

    1. Configure logging in Varnish

    2. Configure Sumo Logic Installed Collector

Step 1 Configure Metrics Collection

  1. Configure a Hosted Collector
    To create a new Sumo Logic hosted collector, perform the steps in the Configure a Hosted Collector section of the Sumo Logic documentation.

  2. Configure an HTTP Logs and Metrics Source
    Create a new HTTP Logs and Metrics Source in the hosted collector created above by following these instructions. Make a note of the HTTP Source URL.

  3. Install Telegraf
    Use the following steps to install Telegraf.

  4. Configure and start Telegraf
    As part of collecting metrics data from Telegraf, we will use the Varnish input plugin to get data from Telegraf and the Sumo Logic output plugin to send data to Sumo Logic. 

    Create or modify telegraf.conf and copy and paste the text below:  

  use_sudo = true
  binary = "/usr/bin/varnishstat"
  stats = ["*"]
  [inputs.varnish.tags]
   component="cache"
   environment="dev_CHANGME"
   cache_system="varnish"
   cache_cluster="varnish_on_premise_CHANGEME"


  url = "<URL Created in Step 3_CHANGEME>”
  data_format = "prometheus"

 Please enter values for the following parameters (marked in bold above):

  • In the input plugins section, which is [[inputs.varnish]]

    • binary -  The default location of the varnish stat binary. Please override as per your configuration.

    • use_sudo - If running as a restricted user, prepend sudo for additional access.

    • stats - Stats may also be set to ["*"], which will collect all stats. Please see this doc for more information on additional parameters for configuring the Varnish input plugin for Telegraf.

    • In the tags section, which is [inputs.varnish.tags]

      • environment - This is the deployment environment where the Varnish cluster identified by the value of servers resides. For example; dev, prod or qa. While this value is optional we highly recommend setting it. 

      • cache_cluster - Enter a name to identify this Varnish cluster. This cluster name will be shown in the Sumo Logic dashboards. 

  • In the output plugins section, which is [[outputs.sumologic]]

    • url - This is the HTTP source URL created in step 3. Please see this doc for more information on additional parameters for configuring the Sumo Logic Telegraf output plugin.

Here’s an explanation for additional values set by this Telegraf configuration that we request you please do not modify as they will cause the Sumo Logic apps to not function correctly.

  • data_format - “prometheus” In the output plugins section, which is [[outputs.sumologic]]. Metrics are sent in the Prometheus format to Sumo Logic

  • Component: “cache” - In the input plugins section, which is,

[[inputs.varnish]] - This value is used by Sumo Logic apps to identify application components.

  • cache_system: “varnish” - In the input plugins sections. In other words, this value identifies the cache system

  •  For all other parameters please see this doc for more properties that can be configured in the Telegraf agent globally.

Once you have finalized your telegraf.conf file, you can start or reload the telegraf service using instructions from the doc.

At this point, Varnish metrics should start flowing into Sumo Logic.

Step 2 Configure Logs Collection

This section provides instructions for configuring log collection for Varnish running on a non-kubernetes environment for the Sumo Logic App for Varnish. 

By default, Varnish logs are stored in a log file. Sumo Logic supports collecting logs via a local log file. Local log files can be collected via Installed collectors. An Installed collector will require you to allow outbound traffic to Sumo Logic endpoints for collection to work. For detailed requirements for Installed collectors, see this page.

 

  1. Configure logging in Varnish
    Varnish supports logging via the following methods: local text log files. For details please visit this page.
    For the dashboards to work properly, please set the below specified log format as explained here
    %h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"

  2. Configure Varnish to log to a Local file
    By default any installation of varnishd will not write any request logs to disk. Instead 
    Varnish has an in-memory log, and supplies tools to tap into this log and write to disk. To 
    configure logging toa local file, follow the steps on this page.
    By default, Varnish logs are stored in /var/log/varnish/varnishncsa.log. For customized options please visit this page.
    Logs from the Varnish log file can be collected via a Sumo Logic Installed collector and a Local File Source as explained in the next section.

  3. Configuring a Collector
    To add an Installed collector, perform the steps as defined on the page Configure an Installed Collector.

  4. Configuring a Source
    To add a Local File Source source for Varnish do the following
    To collect logs directly from your Varnish machine, use an Installed Collector and a Local File Source.  

    1. Add a Local File Source.

    2. Configure the Local File Source fields as follows:

  • Name. (Required)
  • Description. (Optional)
  • File Path (Required). Enter the path to your error.log or access.log. The files are typically located in /var/log/varnish/varnishncsa.log.
  • Source Host. Sumo Logic uses the hostname assigned by the OS unless you enter a different host name
  • Source Category. Enter any string to tag the output collected from this Source, such as Varnish/Logs. (The Source Category metadata field is a fundamental building block to organize and label Sources. For details see Best Practices.)

Fields. Set the following fields:

  • component = cache
  • cache_system = varnish
  • cache_cluster = <Your_Varnish_Cluster_Name>
  • environment = <Environment_Name>, such as Dev, QA or Prod.

  1. Configure the Advanced section:

  • Enable Timestamp Parsing. Select Extract timestamp information from log file entries.
  • Time Zone. Choose the option, Ignore time zone from log file and instead use, and then select your Varnish Server’s time zone.
  • Timestamp Format. The timestamp format is automatically detected.
  • Encoding. Select UTF-8 (Default).
  • Enable Multiline Processing. Detect messages spanning multiple lines
    • Infer Boundaries - Detect message boundaries automatically
  1. Click Save.
    At this point, Varnish logs should start flowing into Sumo Logic.