Fastly StatsTrigger

Fastly StatsTrigger

Certified

Trigger when a Fastly field metric crosses a threshold

Polls /stats/service/{serviceId}/field/{field} on the configured interval, sums all numeric values of the chosen field across data points in the window, and fires an execution when the observed value matches the threshold according to the comparator.

Useful for alerting on error spikes (e.g. status_5xx > 100), hit-ratio drops (e.g. hit_ratio < 0.8), or bandwidth surges.

yaml
type: io.kestra.plugin.fastly.stats.StatsTrigger

Alert when 5xx errors exceed 50 in the past hour

yaml
id: fastly_error_alert
namespace: company.ops

triggers:
  - id: high_error_rate
    type: io.kestra.plugin.fastly.stats.StatsTrigger
    apiToken: "{{ secret('FASTLY_API_TOKEN') }}"
    serviceId: "{{ secret('FASTLY_SERVICE_ID') }}"
    field: "status_5xx"
    threshold: 50
    comparator: GREATER_THAN
    window: "PT1H"
    interval: PT5M

tasks:
  - id: alert
    type: io.kestra.plugin.core.log.Log
    message: "5xx spike detected: {{ trigger.value }} errors (threshold: {{ trigger.threshold }})"
Properties

Fastly API token

Your Fastly API token. The token must have global: read scope to access stats endpoints.

Field name

Fastly stats field to aggregate and compare, e.g. status_5xx, errors, hit_ratio, bandwidth.

Service ID

The Fastly service to monitor.

Threshold value

The numeric value to compare the observed field sum against.

Defaultfalse

Specifies whether a trigger is allowed to start a new execution even if a previous run is still in progress.

Defaulthttps://api.fastly.com

Fastly API base URL

Base URL for the Fastly API. Override this only for testing.

Defaultminute

Aggregation granularity

Time bucket size for the data points fetched from Fastly. One of minute, hour, or day. Defaults to minute. Note that the Fastly API returns at most 200 data points per request; a large window combined with fine granularity (e.g. a 4-hour window with minute buckets) will exceed this cap and truncate the observed window. Choose by to stay within 200 points.

DefaultGREATER_THAN
Possible Values
GREATER_THANGREATER_THAN_OR_EQUALLESS_THANLESS_THAN_OR_EQUALEQUAL

Comparator

Comparison operator applied between the observed value and threshold. Available values: GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, EQUAL. Defaults to GREATER_THAN.

DefaultPT1M
Formatduration

Interval between polling.

The interval between 2 different polls of schedule, this can avoid to overload the remote system with too many calls. For most of the triggers that depend on external systems, a minimal interval must be at least PT30S. See ISO_8601 Durations for more information of available interval values.

HTTP client options

Optional advanced HTTP settings such as timeouts or proxy configuration.

Definitions
allowFailedbooleanstring
Defaultfalse

If true, allow a failed response code (response code >= 400)

allowedResponseCodesarray
SubTypeinteger

List of response code allowed for this request

auth

The authentication to use.

type*Requiredobject
passwordstring

The password for HTTP basic authentication.

usernamestring

The username for HTTP basic authentication.

type*Requiredobject
tokenstring

The token for bearer token authentication.

type*Requiredobject
passwordstring

The password for HTTP Digest authentication.

usernamestring

The username for HTTP Digest authentication.

defaultCharsetstring
DefaultUTF-8

The default charset for the request.

enabledTcpExtendedKeepAlivebooleanstring
Defaulttrue

Whether to enable TCP Keep-Alive extended socket options (TCP_KEEPIDLE, TCP_KEEPINTERVAL, TCP_KEEPCOUNT).

Set to false when running on Windows workers, as these extended socket options are not supported by the Windows JDK and will cause connection failures.

followRedirectsbooleanstring
Defaulttrue

Whether redirects should be followed automatically.

logsarray
SubTypestring
Possible Values
REQUEST_HEADERSREQUEST_BODYRESPONSE_HEADERSRESPONSE_BODY

The enabled log.

proxy

The proxy configuration.

addressstring

The address of the proxy server.

passwordstring

The password for proxy authentication.

portintegerstring

The port of the proxy server.

typestring
DefaultDIRECT
Possible Values
DIRECTHTTPSOCKS

The type of proxy to use.

usernamestring

The username for proxy authentication.

ssl

The SSL request options

insecureTrustAllCertificatesbooleanstring

Whether to disable checking of the remote SSL certificate.

Only applies if no trust store is configured. Note: This makes the SSL connection insecure and should only be used for testing. If you are using a self-signed certificate, set up a trust store instead.

timeout

The timeout configuration.

connectTimeoutstring

The time allowed to establish a connection to the server before failing.

readIdleTimeoutstring
DefaultPT5M

The time allowed for a read connection to remain idle before closing it.

SubTypestring
Possible Values
CREATEDSUBMITTEDRUNNINGPAUSEDRESTARTEDKILLINGSUCCESSWARNINGFAILEDKILLEDCANCELLEDQUEUEDRETRYINGRETRIEDSKIPPEDBREAKPOINTRESUBMITTED

List of execution states after which a trigger should be stopped (a.k.a. disabled).

Defaulttrue

A condition that determines whether the trigger should run.

A Pebble expression evaluated at trigger time. The trigger fires only when the expression evaluates to a truthy value (true, a non-empty string, a non-zero number). Use this to gate trigger execution on dynamic runtime values such as execution labels, flow variables, or environment conditions.

DefaultPT1H

Observation window

How far back to look for data points. Data points within [now - window, now] are summed.

Field name

The Fastly stats field that was monitored.

Threshold value

The threshold that was configured and matched.

Observed value

The sum of the monitored field across all data points in the observation window.