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

short_name: Varnish
app_url: "https://varnish-cache.org/"
long_name: Varnish HTTP Cache
logo_path: /images/partners/varnish-logo.png # supplied by google technical writer
description: |-
  The Varnish integration collects cache and session metrics.
  It monitors the number of objects entering and exiting the cache,
  as well as the number of sessions and backend connections.
  The integration also collects Varnish logs and parses them
  into a standardized JSON payload.
supported_app_version: ["6.x", "7.0.x"]
configure_integration: |-
  The Varnish logging processor processes logs using
  [varnishncsa](https://varnish-cache.org/docs/6.0/reference/varnishncsa.html).
  Varnish can enable varnishncsa logging by following this [guide](https://docs.varnish-software.com/tutorials/enabling-logging-with-varnishncsa/),
  depending on the operating system.

  By default, logs are written to `/var/log/varnish/varnishncsa.log`. If you
  choose another destination, you must update the receiver configuration.
  Logs are expected to be in the default format, and a log rotation should be
  set up.
expected_metrics:
  - type: workload.googleapis.com/varnish.backend.connection.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: kind
        value_regex: .*
    representative: true
  - type: workload.googleapis.com/varnish.backend.request.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/varnish.cache.operation.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: operation
        value_regex: .*
  - type: workload.googleapis.com/varnish.client.request.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: state
        value_regex: .*
  - type: workload.googleapis.com/varnish.client.request.error.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: status_code
        value_regex: .*
  - type: workload.googleapis.com/varnish.object.count
    value_type: INT64
    kind: GAUGE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/varnish.object.expired
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/varnish.object.moved
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/varnish.object.nuked
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
  - type: workload.googleapis.com/varnish.session.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: kind
        value_regex: .*
  - type: workload.googleapis.com/varnish.thread.operation.count
    value_type: INT64
    kind: CUMULATIVE
    monitored_resources: [gce_instance]
    labels:
      - name: operation
        value_regex: .*
configuration_options:
  logs:
    - type: varnish
      fields:
        - name: type
          default: null
          description: This value must be `varnish`.
        - name: include_paths
          default: '[/var/log/varnish/varnishncsa.log]'
          description: A `varnishncsa` default log path to read by tailing each file.
        - 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: varnish
      fields:
        - name: type
          default: null
          description: This value must be `varnish`.
        - name: cache_dir
          default: null
          description: This specifies the cache dir instance name to use when collecting metrics. If not specified, defaults to the host.
        - name: exec_dir
          default: null
          description: The directory where the `varnishadm` and `varnishstat` executables are located. If not provided, relies on the executables being in the user's `PATH`.
        - name: collection_interval
          default: 60s
          description: A [time duration](https://pkg.go.dev/time#ParseDuration) value, such as `30s` or `5m`.
minimum_supported_agent_version:
  metrics: 2.15.0
  logging: 2.16.0
supported_operating_systems: linux
platforms_to_skip:
  # varnish is not supported on sles
  - suse-cloud:sles-12
  - suse-cloud:sles-15
  - suse-cloud:sles-15-arm64
expected_logs:
  - log_name: varnish
    fields:
      - name: httpRequest.remoteIp
        value_regex: 127.0.0.1
        type: string
        description: The IP address (IPv4 or IPv6) of the client that issued the HTTP request
        optional: true
      - name: httpRequest.requestMethod
        value_regex: GET
        type: string
        description: HTTP method
        optional: true
      - name: jsonPayload.host
        type: string
        description: Contents of the Host header
        optional: true
      - name: jsonPayload.user
        type: string
        description: Authenticated username for the request
        optional: true
      - name: httpRequest.requestUrl
        value_regex: .*/forbidden.html
        type: string
        description: Request URL (typically just the path part of the URL
        optional: true
      - name: httpRequest.protocol
        value_regex: HTTP/1.1
        type: string
        description: Protocol used for the request
        optional: true
      - name: httpRequest.status
        type: string
        description: HTTP status code
        optional: true
      - name: httpRequest.responseSize
        type: string
        description: Response size
        optional: true
      - name: httpRequest.referer
        type: string
        description: Contents of the `Referer` header
        optional: true
      - name: httpRequest.userAgent
        type: string
        description: Contents of the `User-Agent` header
        optional: true
      - name: severity
        type: string
        description: ''
public_url: https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/third-party/varnish
