Skip to main content
Sumo Logic

Collect Cassandra Logs and Metrics for Non-Kubernetes environments

This page provides instructions for configuring log and metric collection for the Sumo Logic App for Cassandra.

Cassandra metrics collection setup can be done in two ways.

  1. Using Telegraf and Installed Collector
  2. Using Open Telemetry Collection

Both the methods require the Jolokia agent to collect metrics. The steps to configure Jolokia JVM Agent in Cassandra are as below:

  1. Download the latest Jolokia JVM agent jar file (example: jolokia-jvm-1.3.3-agent.jar) from here.
  2. Copy the downloaded jar file to Cassandra’s lib folder (example: /usr/share/cassandra/lib)
  3. In cassandra-env.sh file, enable/add the following lines:
    # Jolokia javaagent
    JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jolokia-jvm-1.3.3-agent.jar"
  4. Restart Cassandra service.

Below we have defined both the ways in which collection can be configured.

Using Telegraf and Installed Collector

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

This section provides instructions for configuring metrics collection for the Sumo Logic App for Cassandra. 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 Cassandra
    2. Configure Sumo Logic Installed Collector

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.

  1. 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.

  1. Install Telegraf

Use the following steps to install Telegraf.

  1. Configure and start Telegraf

As part of collecting metrics data from Telegraf, we will use the jolokia2 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:  


[[inputs.jolokia2_agent]]
 urls = ["http://localhost:8778/jolokia"]
 name_prefix = "cassandra_java_"
[inputs.jolokia2_agent.tags]
 environment="<Your_Environment_Name>"
 component="database"
 db_system="cassandra"
 db_cluster="<Your_Cassandra_Cluster_Name>"
 dc = "IDC1"
[[inputs.jolokia2_agent.metric]]
 name  = "Memory"
 mbean = "java.lang:type=Memory"
[[inputs.jolokia2_agent.metric]]
 name  = "GarbageCollector"
 mbean = "java.lang:name=*,type=GarbageCollector"
 tag_keys = ["name"]
 field_prefix = "$1_"
 
[[inputs.jolokia2_agent.metric]]
 name="OperatingSystem"
 mbean="java.lang:type=OperatingSystem"
 paths=["FreePhysicalMemorySize","AvailableProcessors","SystemCpuLoad","TotalPhysicalMemorySize","TotalSwapSpaceSize","SystemLoadAverage"]
[[inputs.jolokia2_agent]]
 urls = ["http://localhost:8778/jolokia"]
 name_prefix = "cassandra_"
[inputs.jolokia2_agent.tags]
 environment="<Your_Environment_Name>"
 component="database"
 db_system="cassandra"
 db_cluster="<Your_Cassandra_Cluster_Name>"
 db_cluster_address = “ENV_TO_BE_CHANGED”
 db_cluster_port = “ENV_TO_BE_CHANGED”
 dc = "IDC1"
[[inputs.jolokia2_agent.metric]]
   name  = "TableMetrics"
   mbean = "org.apache.cassandra.metrics:name=*,scope=*,keyspace=*,type=Table"
   tag_keys = ["name", "scope","keyspace"]
   field_prefix = "$1_"
[[inputs.jolokia2_agent.metric]]
   name = "DroppedMessageMetrics"
   mbean = "org.apache.cassandra.metrics:name=*,scope=*,type=DroppedMessage"
   tag_keys = ["name", "scope"]
   field_prefix = "$1_"
[[inputs.jolokia2_agent.metric]]
   name = "ClientMetrics"
   mbean = "org.apache.cassandra.metrics:type=Client,name=*"
   tag_keys = ["name"]
   field_prefix = "$1_"
[[inputs.jolokia2_agent.metric]]
   name = "ThreadPoolMetrics"
   mbean = "org.apache.cassandra.metrics:type=ThreadPools,path=*,scope=*,name=*"
   tag_keys = ["name", "scope", "path"]
   field_prefix = "$1_"
[[inputs.jolokia2_agent.metric]]
   name = "CacheMetrics"
   mbean = "org.apache.cassandra.metrics:type=Cache,scope=*,name=*"
   tag_keys = ["name", "scope"]
   field_prefix = "$1_"
[[inputs.jolokia2_agent.metric]]
   name = "CommitLogMetrics"
   mbean = "org.apache.cassandra.metrics:type=CommitLog,name=*"
   tag_keys = ["name"]
   field_prefix = "$1_"
[[outputs.sumologic]]
 url = "<URL Created in Step 3>"
 data_format = "prometheus"
[outputs.sumologic.tagpass]
 db_cluster=["<Your_Cassandra_Cluster_Name>"]

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

  • In the input plugins section, which is [[inputs. jolokia2_agent]]:
    • urls - The URL to the jolokia server. Please see this doc for more information on additional parameters for configuring the Cassandra input plugin for Telegraf.
  • In the tags section, which is [inputs.Cassandra.tags]:
    • environment - This is the deployment environment where the Cassandra cluster identified by the value of servers resides. For example: dev, prod or qa. While this value is optional we highly recommend setting it. 
    • db_cluster - Enter a name to identify this Cassandra cluster. This cluster name will be shown in the Sumo Logic dashboards. 
    • db_cluster_address - Enter the cluster hostname or ip address that is used by the application to connect to the database. It could also be the load balancer or proxy endpoint.

    • db_cluster_port - Enter the database port. If not provided, a default port will be used.

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

  • In the tags section ([inputs.jolokia2_agent.tags]):

    • component: “database” - This value is used by Sumo Logic apps to identify application components.

    • db_system: “cassandra” - This value identifies the database system.

  • 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 not to function correctly.
    • data_format - “prometheus” In the output plugins section, which is [[outputs.sumologic]]. Metrics are sent in the Prometheus format to Sumo Logic
    • db_system: “cassandra” - In the input plugins section:  This value identifies the database system.
    • component: “database” - In the input plugins section: This value identifies application components.
  • 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, Cassandra metrics should start flowing into Sumo Logic.

Configure Logs Collection

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

By default, Cassandra logs are stored in a log file. 

Sumo Logic supports collecting logs from a local log file by using a local file source via Installed collectors. The 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.

Based on your infrastructure and networking setup choose one of these methods to collect Cassandra logs and follow the instructions below to set up log collection:

  1. Configure logging in Cassandra

Cassandra supports logging via the local text log files. Cassandra logs have the following levels of verbosity. To select a level, set loglevel to one of:

  • ALL
  • TRACE
  • DEBUG
  • INFO (Default)
  • WARN
  • ERROR
  • OFF

To permanently add debug logging to a class using the logback framework, use nodetool setlogginglevel to check you have the right class before you set it in the logback.xml file in install_location/conf. Modify to include the following line or similar at the end of the file:

<logger name="org.apache.cassandra.gms.FailureDetector" level="DEBUG"/>

Restart the node to invoke the change.

  1. Configure Cassandra to log to a Local file

Cassandra provides logging functionality using Simple Logging Facade for Java (SLF4J) with a logback backend. Cassandra has three main logs, the system.logdebug.log, and gc.log which hold general logging messages, debugging logging messages, and java garbage collection logs, respectively.

These logs, by default, live in ${CASSANDRA_HOME}/logs, but most Linux distributions relocate logs to /var/log/cassandra. Operators can tune this location as well as what levels are logged using the provided logback.xml file.

You can configure logging programmatically or manually. Manual ways to configure logging are:

  • Run the nodetool setlogginglevel command.
  • Configure the logback-test.xml or logback.xml file installed with Cassandra.
  • Use the JConsole tool to configure logging through JMX.

Logs from the Cassandra log file can be collected via a Sumo Logic Installed collector and a Local File Source as explained in the next section.

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

  2. Configuring a Source

To add a Local File Source source for Cassandra, do the following

To collect logs directly from your Cassandra 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 log files. The files are typically located in /var/log/cassandra/system.log. If you are using a customized path, check the logback.xml file for this information. 
  • 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 Cassandra/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 = database
    • db_system = cassandra
    • db_cluster = <Your_Cassandra_Cluster_Name>
    • environment = <Environment_Name>, such as Dev, QA or Prod.
    • db_cluster_address - Enter the cluster hostname or ip address that is used by the application to connect to the database. It could also be the load balancer or proxy endpoint.
    • db_cluster_port - Enter the database port. If not provided, a default port will be used
  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 Cassandra 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, Cassandra logs should start flowing into Sumo Logic.

Using Open Telemetry 

We use the Telegraf receiver of Sumo Logic OpenTelemetry Distro Collector for Cassandra metric collection and the Sumo Logic Installed Collector for collecting Cassandra logs. Sumo Logic OT distro runs on the same system as Cassandra, and uses the Cassandra Jolokia input plugin for Telegraf to obtain Cassandra metrics, and the Sumo Logic exporter to send the metrics to Sumo Logic. Cassandra Logs are sent to Sumo Logic Local File Source on Installed Collector.

Configure Metrics and Logs Collection 

  1. Install sumologic-otel-collector by following the instructions mentioned here.
  2. Configure and start sumologic-otel-collector.
    As part of collecting metrics data from Cassandra, we will use the jolokia2 input plugin for Telegraf to get data from otel and then send data to Sumo Logic.
  3. Create or modify config.yaml. Sample config is here

    Please enter values for the following parameters.

  • Enter Sumo Logic collection details in the section; extensions > sumologic by referring to these instructions. Configure details like collector name, category, install token, endpoint etc.

    In the input plugins section, that is [[inputs. jolokia2_agent]]:

    • urls - The URL to the jolokia server. Please see this doc for more information on additional parameters for configuring the Cassandra input plugin for Telegraf.

  • In the tags section, which is [inputs.Cassandra.tags] and filelog section 

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

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

  • In the exporter plugins section : 

    • Enter details like source_category and source_host.  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 not to function correctly.

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

    • db_system: “cassandra” - In the input plugins section:  This value identifies the database system.

    • component: “database” - In the input plugins section: This value identifies application components.

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

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

  1. Run the Sumo Logic OT Distro using the below command 
otelcol-sumo --config config.yaml

At this point, Cassandra metrics and logs should start flowing into Sumo Logic.