# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

public_url: "https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/third-party/solr"
app_url: "https://solr.apache.org/"
short_name: Solr
long_name: Apache Solr
logo_path: /stackdriver/images/solr.png # supplied by google technical writer
description: |-
  The Apache Solr integration collects core and cache metrics. Core metrics focus
  on requests, document count, and index size. Cache metrics focus on cache
  utilization. The integration also collects Solr logs and parses them into a
  JSON payload. The result includes fields for shard, replica, core,
  level, and message.
configure_integration: |-
  To expose a JMX endpoint, you must set the `com.sun.management.jmxremote.port`
  system property when starting the JVM. We also recommend setting the
  `com.sun.management.jmxremote.rmi.port` system property to the same port. To
  expose a JMX endpoint remotely, you must also set the `java.rmi.server.hostname`
  system property.

  By default, these properties are set in a Solr deployment's
  `solr-env.sh` file.

  To set system properties by using command-line arguments, prepend the property
  name with `-D` when starting the JVM. For example, to set
  `com.sun.management.jmxremote.port` to port `18983`, specify the following when
  starting the JVM:

  <pre>
  -Dcom.sun.management.jmxremote.port=18983
  </pre>
minimum_supported_agent_version:
  metrics: 2.10.0
  logging: 2.10.0
supported_operating_systems: linux
supported_app_version: ["8.x", "7.7"]
expected_metrics:
  - type: workload.googleapis.com/solr.cache.eviction.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: cache
        value_regex: .*
      - name: core
        value_regex: .*
  - type: workload.googleapis.com/solr.cache.hit.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: cache
        value_regex: .*
      - name: core
        value_regex: .*
  - type: workload.googleapis.com/solr.cache.insert.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: cache
        value_regex: .*
      - name: core
        value_regex: .*
  - type: workload.googleapis.com/solr.cache.lookup.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: cache
        value_regex: .*
      - name: core
        value_regex: .*
  - type: workload.googleapis.com/solr.cache.size
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
    labels:
      - name: cache
        value_regex: .*
      - name: core
        value_regex: .*
    representative: true
  - type: workload.googleapis.com/solr.document.count
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
    labels:
      - name: core
        value_regex: .*
  - type: workload.googleapis.com/solr.index.size
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
    labels:
      - name: core
        value_regex: .*
  - type: workload.googleapis.com/solr.request.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: core
        value_regex: .*
      - name: handler
        value_regex: .*
      - name: type
        value_regex: .*
  - type: workload.googleapis.com/solr.request.error.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: core
        value_regex: .*
      - name: handler
        value_regex: .*
      - name: type
        value_regex: .*
  - type: workload.googleapis.com/solr.request.time.average
    value_type: DOUBLE
    kind: GAUGE
    monitored_resources: [gce_instance]
    labels:
      - name: core
        value_regex: .*
      - name: handler
        value_regex: .*
      - name: type
        value_regex: .*
  - type: workload.googleapis.com/solr.request.timeout.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: core
        value_regex: .*
      - name: handler
        value_regex: .*
      - name: type
        value_regex: .*
expected_logs:
  - log_name: solr_system
    fields:
      - name: jsonPayload.message
        value_regex: " ___      _       Welcome to Apache Solr™ version 8.11.1"
        type: string
        description: Log message
      - name: jsonPayload.thread
        value_regex: main
        type: string
        description: Thread where the log originated
      - name: jsonPayload.source
        value_regex: o.a.s.s.SolrDispatchFilter
        type: string
        description: Source of where the log originated
      - name: jsonPayload.collection
        type: string
        description: Solr collection related to the log
        optional: true
      - name: jsonPayload.level
        type: string
        description: Log entry level
        optional: true
      - name: jsonPayload.shard
        type: string
        description: Solr shard related to the log
        optional: true
      - name: jsonPayload.replica
        type: string
        description: Solr replica related to the log
        optional: true
      - name: jsonPayload.core
        type: string
        description: Solr core related to the log
        optional: true
      - name: jsonPayload.exception
        type: string
        description: Exception related to the log, including detailed stacktrace where provided
        optional: true
      - name: severity
        type: string
        description: ''
configuration_options:
  logs:
    - type: solr_system
      fields:
        - name: type
          default: null
          description: This value must be `solr_system`.
        - name: include_paths
          default: '[/var/solr/logs/solr.log]'
          description: A list of filesystem paths to read by tailing each file. A wild card (`*`) can be used in the paths.
        - name: exclude_paths
          default: null
          description: A list of filesystem path patterns to exclude from the set matched by `include_paths`.
        - name: record_log_file_path
          default: false
          description: 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.
        - name: wildcard_refresh_interval
          default: 60s
          description: The interval at which wildcard file paths in `include_paths` are refreshed. Given as a [time duration](https://pkg.go.dev/time#ParseDuration), for example `30s` or `2m`. This property might be useful under high logging throughputs where log files are rotated faster than the default interval.
  metrics:
    - type: solr
      fields:
        - name: type
          default: null
          description: This value must be `solr`.
        - name: endpoint
          default: localhost:18983
          description: The [JMX Service URL](https://docs.oracle.com/javase/8/docs/api/javax/management/remote/JMXServiceURL.html) or host and port used to construct the Service URL. Must be in the form of `host:port`. Values in `host:port` form will be used to create a Service URL of `service:jmx:rmi:///jndi/rmi://<host>:<port>/jmxrmi`.
        - name: username
          default: null
          description: The configured username if JMX is configured to require authentication.
        - name: password
          default: null
          description: The configured password if JMX is configured to require authentication.
        - name: collection_interval
          default: 60s
          description: A [time duration](https://pkg.go.dev/time#ParseDuration) value, such as `30s` or `5m`.
