The Observability Blog

Categories:
  • Google Cloud
  • Metrics
  • OpenTelemetry

How to monitor Jetty using OpenTelemetry

by Miguel Rodriguez on
July 26, 2022

You can now monitor Jetty for free using top of the line open source monitoring tools in OpenTelemetry. If you are as excited as we are, take a look at the details of this support in OpenTelemetry’s repo. 

The best part is that this receiver works with any OpenTelemetry collector: including the OpenTelemetry Collector and  observIQ’s distribution of the collector. 

Jetty uses the JMX receiver. In this post, we take you through the steps to set up the JMX receiver with the observIQ OpenTelemetry collector, configure it for Jetty, and send out the metrics to Google Cloud. 

What signals matter?

Jetty only produces seven metrics–you can see a full list below near the end of the blog. The three metrics that you likely want to pay the closest attention to are the jetty.select.count, jetty.session.count, and jetty.session.time.total. 

  • Select Count
    • Monitors the number of select calls to the server.
  • Session Count
    • Monitors the number of sessions created in the server.
  • Session Time
    • Monitors the total amount of time sessions are active.

Configuring the JMX metrics receiver

After the installation, the config file for the collector can be found at: 

  • C:\Program Files\observIQ OpenTelemetry Collector\config.yaml (Windows)
  • /opt/observiq-otel-collector/config.yaml(Linux)

The first step is building the receiver’s configuration:

  • We are using the JMX receiver to gather jetty metrics. The jar_path attribute lets you specify the path to the jar file that facilitates gathering jetty metrics using the JMX receiver. This file path is created automatically when the observIQ OpenTelemetry collector is installed. 
  • Set the IP address and port for the system from which the metrics are gathered as the endpoint.
  • When we connect to JMX there are different categories of metrics; the jetty metrics and JVM metrics are the ones that this configuration intends to scrape. This target_system attribute specifies that. 
  • Set the time interval for fetching the metrics for the collection_interval attribute. The default value for this parameter is 10s. However, if exporting metrics to Google Cloud, this value is set to 60s by default. 

The Properties attribute allows you to set arbitrary attributes. For instance, if you are configuring multiple JMX receivers to collect metrics from many jetty servers, this attribute allows you to set the unique IP addresses for each of those endpoint systems. Please note that this is not the only use of the properties option.

receivers:
  jmx:
    jar_path: /opt/opentelemetry-java-contrib-jmx-metrics.jar
    endpoint: localhost:1099
    target_system: jetty,jvm
    collection_interval: 60s
    resource_attributes:
      jetty.endpoint: localhost:1099

Set up a destination for exporting the metrics as shown below. 
You can check the configuration for your preferred destination from OpenTelemetry’s documentation here.

exporters: 
  googlecloud:
    metric:
      resource_filters:
        - prefix: jetty

Set up the pipeline.

service:
  pipelines:
    metrics:
      receivers:
      - jmx
      exporters:
      - googlecloud

Viewing the metrics collected 

The JMX metrics gatherer scrapes the following metrics and exports them to the destination, based on the config detailed above. 

MetricDescription
jetty.select.count

The number of select calls.

jetty.session.count

The number of sessions created.

jetty.client.request.range_slice.latency.50p

The total number of requests that are range sliced at 50%

jetty.session.time.total

The total time sessions have been active.

jetty.session.time.max
The maximum amount of time a session has been active.

jetty.thread.count

The current number of threads.

jetty.thread.queue.count

The current number of threads in the queue.

observIQ’s distribution is a game-changer for companies looking to implement the OpenTelemetry standards. The single line installer, seamlessly integrated receivers, exporter, and processor pool make working with this collector simple. Follow this space to keep up with all our future posts and simplified configurations for various sources. For questions, requests, and suggestions, reach out to our support team at support@observIQ.com.