The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojo::Netdata::Collector::HTTP - A HTTP collector for Mojo::Netdata

SYNOPSIS

Supported variant of "config" in Mojo::Netdata:

{
  collectors => [
    {
      # It is possible to load this collector multiple times
      class           => 'Mojo::Netdata::Collector::HTTP',
      connect_timeout => 5, # Optional
      request_timeout => 5, # Optional
      update_every    => 30,
      jobs            => {
        # The key is the URL to request
        'https://example.com' => {

          # Optional
          method => 'GET',               # GET (Default), HEAD, POST, ...
          headers => {'X-Foo' => 'bar'}, # HTTP headers

          # Set this to also send the request directly to an IP,
          # with the "Host" headers set to the host part of "url".
          direct_ip => '192.0.2.42',

          # Set "family" to group multiple domains together in one chart,
          # Default value is either "direct_ip" or the host part of the URL.
          family => 'test',

          # Only one of these can be present
          json   => {...},           # JSON HTTP body
          form   => {key => $value}, # Form data
          body   => '...',           # Raw HTTP body
        },
      },
    },
  ],
}

DESCRIPTION

Mojo::Netdata::Collector::HTTP is a collector that can chart a web page response time and HTTP status codes.

ATTRIBUTES

context

$str = $collector->context;

Defaults to "web".

type

$str = $collector->type;

Defaults to "http".

ua

$ua = $collector->ua;

Holds a Mojo::UserAgent.

update_every

$num = $chart->update_every;

Default value is 30. See "update_every" in Mojo::Netdata::Collector for more details.

METHODS

register

$collector = $collector->register(\%config, $netdata);

Returns a $collector object if any "jobs" are defined in %config. Will also set "update_every" from %config or use "update_every" in Mojo::Netdata if it is 10 or greater.

update_p

$p = $collector->update_p;

Gathers information about the "jobs" registered.

SEE ALSO

Mojo::Netdata and Mojo::Netdata::Collector.