# 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/jetty"
app_url: "https://www.eclipse.org/jetty/"
short_name: Jetty
long_name: Jetty
logo_path: /stackdriver/images/jetty.png # supplied by google technical writer
description: |-
  The Jetty integration collects session and thread-usage metrics. The
  integration also collects access and system logs. Access logs are parsed
  into a JSON payload focused on request details.
configure_integration: |-
  To collect metrics from this integration, you must expose a
  [Java Management Extensions (JMX)](https://www.oracle.com/java/technologies/javase/javamanagement.html)
  endpoint.

  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 the Jetty `/etc/jetty-jmx.xml` 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 1099, specify the following when
  starting the JVM:

  <pre>
  -Dcom.sun.management.jmxremote.port=1099
  </pre>
minimum_supported_agent_version:
  metrics: 2.17.0
  logging: 2.16.0
supported_operating_systems: linux
supported_app_version: ["9.4.x", "10.x", "11.x"]
expected_metrics:
  - type: workload.googleapis.com/jetty.select.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    representative: true
  - type: workload.googleapis.com/jetty.session.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: resource
        value_regex: .*
  - type: workload.googleapis.com/jetty.session.time.total
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
    labels:
      - name: resource
        value_regex: .*
  - type: workload.googleapis.com/jetty.session.time.max
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
    labels:
      - name: resource
        value_regex: .*
  - type: workload.googleapis.com/jetty.thread.count
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
    labels:
      - name: state
        value_regex: .*
  - type: workload.googleapis.com/jetty.thread.queue.count
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
expected_logs:
  - log_name: jetty_access
    fields:
      - name: httpRequest.remoteIp
        type: string
        description: ''
        optional: true
      - name: httpRequest.requestUrl
        value_regex: \/forbidden.html\?something=something
        type: string
        description: ''
        optional: true
      - name: httpRequest.protocol
        value_regex: HTTP\/1.1
        type: string
        description: ''
        optional: true
      - name: httpRequest.requestMethod
        value_regex: GET
        type: string
        description: ''
        optional: true
      - name: httpRequest.userAgent
        value_regex: curl\/.*
        type: string
        description: ''
        optional: true
      - name: httpRequest.responseSize
        type: string
        description: ''
        optional: true
      - name: httpRequest.status
        type: string
        description: ''
      - name: severity
        type: string
        description: ''
  - log_name: syslog
    fields:
      - name: jsonPayload.message
        type: string
        description: 'Log message'
configuration_options:
  logs:
    - type: jetty_access
      fields:
        - name: type
          default: null
          description: This value must be `jetty_access`.
        - name: include_paths
          default: '["/opt/logs/*.request.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: jetty
      fields:
        - name: type
          default: null
          description: This value must be `jetty`.
        - name: endpoint
          default: localhost:1099
          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. This value must be in the form of `service:jmx:<protocol>:<sap>` or `host:port`. Values in `host:port` form are used to create a service URL of `service:jmx:rmi:///jndi/rmi://<host>:<port>/jmxrmi`.
        - name: collect_jvm_metrics
          default: true
          description: Configures the receiver to also collect the supported JVM metrics.
        - 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`.
