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

type: varnish

status:
  class: receiver
  stability:
    beta: [metrics]

resource_attributes:
  varnish.cache.name:
    description: The name of the cache.
    type: string

attributes:
  backend_connection_type:
    type: string
    name_override: kind
    description: The backend connection types.
    enum: [success, recycle, reuse, fail, unhealthy, busy, retry]
  cache_operations:
    type: string
    name_override: operation
    description: The cache operation types
    enum: [hit, miss, hit_pass]
  thread_operations:
    type: string
    name_override: operation
    description: The thread operation types.
    enum: [created, destroyed, failed]
  session_type:
    type: string
    name_override: kind
    description: The session connection types.
    enum: [accepted, dropped, failed]
  state:
    type: string
    name_override: state
    description: The client request states.
    enum: [received, dropped]
  http.status_code:
    type: string
    name_override: status_code
    description: An HTTP status code.

metrics:
  varnish.backend.connection.count:
    enabled: true
    description: The backend connection type count.
    unit: "{connections}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: [backend_connection_type]
  varnish.cache.operation.count:
    enabled: true
    description: The cache operation type count.
    unit: "{operations}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: [cache_operations]
  varnish.thread.operation.count:
    enabled: true
    description: The thread operation type count.
    unit: "{operations}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: [thread_operations]
  varnish.session.count:
    enabled: true
    description: The session connection type count.
    unit: "{connections}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: [session_type]
  varnish.object.nuked:
    enabled: true
    description: The objects that have been forcefully evicted from storage count.
    unit: "{objects}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: []
  varnish.object.moved:
    enabled: true
    description: The moved operations done on the LRU list count.
    unit: "{objects}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: []
  varnish.object.expired:
    enabled: true
    description: The expired objects from old age count.
    unit: "{objects}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: []
  varnish.object.count:
    enabled: true
    description: The HTTP objects in the cache count.
    unit: "{objects}"
    sum:
      value_type: int
      monotonic: false
      aggregation_temporality: cumulative
    attributes: []
  varnish.client.request.count:
    enabled: true
    description: The client request count.
    unit: "{requests}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: [state]
  varnish.client.request.error.count:
    enabled: true
    description: The client request errors received by status code.
    unit: "{requests}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: [http.status_code]
  varnish.backend.request.count:
    enabled: true
    description: The backend requests count.
    unit: "{requests}"
    sum:
      value_type: int
      monotonic: true
      aggregation_temporality: cumulative
    attributes: []
