---
name: "Net::Prometheus::Counter"
section: "3pm"
platform: "linux"
package: "libnet-prometheus-perl"
version: "0.14-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::Prometheus::Counter"
---

# Net::Prometheus::Counter(3pm)

a monotonically-increasing counter metric

## NAME

"Net::Prometheus::Counter" - a monotonically-increasing counter metric

## SYNOPSIS

```
   use Net::Prometheus;
   my $client = Net::Prometheus->new;
   my $counter = $client->new_counter(
      name => "requests",
      help => "Number of received requests",
   );
   sub handle_request
   {
      $counter->inc;
      ...
   }
```

## DESCRIPTION

This class provides a counter metric - a value that monotonically increases, usually used to represent occurrences of some event that happens within the instrumented program. It is a subclass of Net::Prometheus::Metric.

## CONSTRUCTOR

Instances of this class are not usually constructed directly, but instead via the Net::Prometheus object that will serve it:

```
   $counter = $prometheus->new_counter( %args );
```

This takes the same constructor arguments as documented in Net::Prometheus::Metric.

## METHODS

### inc

```
   $counter->inc( @label_values, $delta );
   $counter->inc( \%labels, $delta );
   $child->inc( $delta );
```

Increment the current value for the gauge. `$delta` will default to 1 if not supplied and must be non-negative.

## AUTHOR

Paul Evans \<leonerd@leonerd.org.uk\>
