Docs
Launch GraphOS Studio

Conditions

Set conditions for when events or instruments are triggered


This feature is only available with a GraphOS Dedicated or Enterprise plan.
To compare GraphOS feature support across all plan types, see the pricing page.

You can set conditions for when an instrument should be mutated or an event should be triggered.

Condition configuration

Here is an example of a condition on a custom instrument:

router.yaml
telemetry:
instrumentation:
instruments:
router:
my.instrument:
value: duration
type: counter
unit: s
description: "my description"
# ...
# This instrument will only be mutated if the condition evaluates to true
condition:
all:
- any:
- eq:
- "val"
- request_header: x-req-header
- eq:
- "foo"
- response_header: x-resp-header

exists

The exists condition is testing if selectors is present.

For example, the following condition checks the value of x-req-header exists:

exists:
- request_header: x-req-header

eq

The eq condition is an equality test between selectors or values.

For example, the following condition checks the value of x-req-header is equal to val:

eq:
- "val"
- request_header: x-req-header

You can use selectors on both sides of the equality test:

eq:
- request_header: x-req-header1
- request_header: x-req-header2

Values may be of types string, number or boolean.

not

The not condition is a negation of the nested condition.

For example, the following condition checks the value of x-req-header is not equal to val1:

not:
eq:
- "val1"
- request_header: x-req-header2

all

The all condition is a list of conditions that all must be true in order for the condition to be true.

For example, the following all condition has a list of eq conditions that check the values of x-req-header1 and x-req-header2, and both eq conditions must be true in order for the all condition to be true:

all:
- eq:
- "val1"
- request_header: x-req-header1
- eq:
- "val2"
- request_header: x-req-header2

any

The any condition is a list of conditions of which at least one must be true for the condition to be true.

For example, the following any condition has a list of eq conditions that check the values of x-req-header1 and x-req-header2, and at least one of the eq conditions must be true in order for the all condition to be true:

any:
- eq:
- "val2"
- request_header: x-req-header1
- eq:
- "val2"
- request_header: x-req-header2

Condition configuration reference

The available basic conditions:

ConditionDescription
eqAn equality test between selectors or values
existA check to see if the selectors value exists
notA negated equality test between selectors or values
allA list of conditions that must all be true
anyA list of conditions of which at least one must be true

You can create complex conditions by using these basic conditions as building blocks.

Next
Introduction
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company