Elasticsearch 7.9+

Elasticsearch is an open-source search server, based on the Lucene search library. It runs in a Java virtual machine on top of a number of operating systems. The elasticsearch receiver collects node- and cluster-level telemetry from your Elasticsearch instances.

For more information about Elasticsearch, see the Elasticsearch 7.9+ documentation.

Prerequisites

To collect Elasticsearch telemetry, you must install the Ops Agent:

  • For metrics, install version 2.21.0 or higher.
  • For logs, install version 2.9.0 or higher.

This integration supports Elasticsearch version 7.9+.

Configure your Elasticsearch instance

If you enable Elasticsearch security features, you must configure a user with the monitor or manage cluster privilege.

Configure the Ops Agent for Elasticsearch

Following the guide to Configure the Ops Agent, add the required elements to collect telemetry from Elasticsearch instances, and restart the agent.

Example configuration

The following commands create the configuration to collect and ingest telemetry for Elasticsearch:

# Configures Ops Agent to collect telemetry from the app. You must restart the agent for the configuration to take effect.

set -e

# Check if the file exists
if [ ! -f /etc/google-cloud-ops-agent/config.yaml ]; then
  # Create the file if it doesn't exist.
  sudo mkdir -p /etc/google-cloud-ops-agent
  sudo touch /etc/google-cloud-ops-agent/config.yaml
fi

# Create a back up of the existing file so existing configurations are not lost.
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak

# Configure the Ops Agent.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
metrics:
  receivers:
    elasticsearch:
      type: elasticsearch
  service:
    pipelines:
      elasticsearch:
        receivers:
          - elasticsearch

logging:
  receivers:
    elasticsearch_json:
      type: elasticsearch_json
    elasticsearch_gc:
      type: elasticsearch_gc
  service:
    pipelines:
      elasticsearch:
        receivers:
          - elasticsearch_json
          - elasticsearch_gc
EOF

For these changes to take effect, you must restart the Ops Agent:

Linux

  1. To restart the agent, run the following command on your instance:
    sudo systemctl restart google-cloud-ops-agent
    
  2. To confirm that the agent restarted, run the following command and verify that the components "Metrics Agent" and "Logging Agent" started:
    sudo systemctl status "google-cloud-ops-agent*"
    

Windows

  1. Connect to your instance using RDP or a similar tool and login to Windows.
  2. Open a PowerShell terminal with administrator privileges by right-clicking the PowerShell icon and selecting Run as Administrator
  3. To restart the agent, run the following PowerShell command:
    Restart-Service google-cloud-ops-agent -Force
    
  4. To confirm that the agent restarted, run the following command and verify that the components "Metrics Agent" and "Logging Agent" started:
    Get-Service google-cloud-ops-agent*
    

Configure logs collection

To ingest logs from Elasticsearch, you must create a receiver for the logs that Elasticsearch produces and then create a pipeline for the new receiver.

To configure a receiver for your elasticsearch_json logs, specify the following fields:

Field Default Description
exclude_paths A list of filesystem path patterns to exclude from the set matched by include_paths.
include_paths [/var/log/elasticsearch/*_server.json, /var/log/elasticsearch/*_deprecation.json, /var/log/elasticsearch/*_index_search_slowlog.json, /var/log/elasticsearch/*_index_indexing_slowlog.json, /var/log/elasticsearch/*_audit.json] A list of filesystem paths to read by tailing each file. A wild card (*) can be used in the paths.
record_log_file_path false If set to true, then the path to the specific file from which the log record was obtained appears in the output log entry as the value of the agent.googleapis.com/log_file_path label. When using a wildcard, only the path of the file from which the record was obtained is recorded.
type This value must be elasticsearch_json.
wildcard_refresh_interval 60s The interval at which wildcard file paths in include_paths are refreshed. Given as a time duration, for example 30s or 2m. This property might be useful under high logging throughputs where log files are rotated faster than the default interval.

To configure a receiver for your elasticsearch_gc logs, specify the following fields:

Field Default Description
exclude_paths A list of filesystem path patterns to exclude from the set matched by include_paths.
include_paths [/var/log/elasticsearch/gc.log] A list of filesystem paths to read by tailing each file. A wild card (*) can be used in the paths.
record_log_file_path false If set to true, then the path to the specific file from which the log record was obtained appears in the output log entry as the value of the agent.googleapis.com/log_file_path label. When using a wildcard, only the path of the file from which the record was obtained is recorded.
type This value must be elasticsearch_gc.
wildcard_refresh_interval 60s The interval at which wildcard file paths in include_paths are refreshed. Given as a time duration, for example 30s or 2m. This property might be useful under high logging throughputs where log files are rotated faster than the default interval.

What is logged

The logName is derived from the receiver IDs specified in the configuration. Detailed fields inside the LogEntry are as follows.

The elasticsearch_json logs contain the following fields in the LogEntry:

Field Type Description
jsonPayload.cluster string The cluster emitting the log record
jsonPayload.cluster.name string The name of the cluster emitting the log record
jsonPayload.cluster.uuid string The UUID of the cluster emitting the log record
jsonPayload.component string The component of Elasticsearch that emitted the log
jsonPayload.level string Log entry level
jsonPayload.message string Log message
jsonPayload.node string The node emitting the log record
jsonPayload.node.name string The name of the node emitting the log record
jsonPayload.node.uuid string The UUID of the node emitting the log record
jsonPayload.type string The type of log, indicating which log the record came from (e.g. server indicates this LogEntry came from the server log)
severity string (LogSeverity) Log entry level (translated).

The elasticsearch_gc logs contain the following fields in the LogEntry:

Field Type Description
jsonPayload.gc_run number The run of the garbage collector
jsonPayload.message string Log message
jsonPayload.type string The type of the log record
severity string (LogSeverity) Log entry level (translated).

Configure metrics collection

To ingest metrics from Elasticsearch, you must create a receiver for the metrics that Elasticsearch produces and then create a pipeline for the new receiver.

This receiver does not support the use of multiple instances in the configuration, for example, to monitor multiple endpoints. All such instances write to the same time series, and Cloud Monitoring has no way to distinguish among them.

To configure a receiver for your elasticsearch metrics, specify the following fields:

Field Default Description
ca_file Path to the CA certificate. As a client, this verifies the server certificate. If empty, the receiver uses the system root CA.
cert_file Path to the TLS certificate to use for mTLS-required connections.
collection_interval 60s A time duration value, such as 30s or 5m.
endpoint http://localhost:92002 The base URL for the Elasticsearch REST API.
insecure true Sets whether or not to use a secure TLS connection. If set to false, then TLS is enabled.
insecure_skip_verify false Sets whether or not to skip verifying the certificate. If insecure is set to true, then the insecure_skip_verify value is not used.
key_file Path to the TLS key to use for mTLS-required connections.
password Password for authentication with Elasticsearch. Required if username is set.
type This value must be elasticsearch.
username Username for authentication with Elasticsearch. Required if password is set.

What is monitored

The following table provides the list of metrics that the Ops Agent collects from the Elasticsearch instance.

Metric type 
Kind, Type
Monitored resources
Labels
workload.googleapis.com/elasticsearch.breaker.memory.estimated
GAUGE, INT64
gce_instance
name
workload.googleapis.com/elasticsearch.breaker.memory.limit
GAUGE, INT64
gce_instance
name
workload.googleapis.com/elasticsearch.breaker.tripped
CUMULATIVE, INT64
gce_instance
name
workload.googleapis.com/elasticsearch.cluster.data_nodes
GAUGE, INT64
gce_instance
 
workload.googleapis.com/elasticsearch.cluster.health
GAUGE, INT64
gce_instance
status
workload.googleapis.com/elasticsearch.cluster.in_flight_fetch
GAUGE, INT64
gce_instance
 
workload.googleapis.com/elasticsearch.cluster.nodes
GAUGE, INT64
gce_instance
 
workload.googleapis.com/elasticsearch.cluster.pending_tasks
GAUGE, INT64
gce_instance
 
workload.googleapis.com/elasticsearch.cluster.published_states.differences
GAUGE, INT64
gce_instance
state
workload.googleapis.com/elasticsearch.cluster.published_states.full
GAUGE, INT64
gce_instance
 
workload.googleapis.com/elasticsearch.cluster.shards
GAUGE, INT64
gce_instance
state
workload.googleapis.com/elasticsearch.cluster.state_queue
GAUGE, INT64
gce_instance
state
workload.googleapis.com/elasticsearch.cluster.state_update.count
CUMULATIVE, INT64
gce_instance
state
workload.googleapis.com/elasticsearch.cluster.state_update.time
CUMULATIVE, INT64
gce_instance
state
type
workload.googleapis.com/elasticsearch.indexing_pressure.memory.limit
GAUGE, INT64
gce_instance
 
workload.googleapis.com/elasticsearch.indexing_pressure.memory.total.primary_rejections
CUMULATIVE, INT64
gce_instance
 
workload.googleapis.com/elasticsearch.indexing_pressure.memory.total.replica_rejections
CUMULATIVE, INT64
gce_instance
 
workload.googleapis.com/elasticsearch.memory.indexing_pressure
GAUGE, INT64
gce_instance
stage
workload.googleapis.com/elasticsearch.node.cache.count
GAUGE, INT64
gce_instance
type
workload.googleapis.com/elasticsearch.node.cache.evictions
CUMULATIVE, INT64
gce_instance
cache_name
workload.googleapis.com/elasticsearch.node.cache.memory.usage
GAUGE, INT64
gce_instance