You are looking at the documentation of a prior release. To read the documentation of the latest release, please visit here.

New to Searchlight? Please start here.

Check json_path

Check command json_path is used to check JSON HTTP response using jq queries.


json_path check command has no variables.

  • url - URL to get data
  • secretName - Name of Kubernetes Secret used to call HTTP api.
  • inClusterConfig - Use InClusterConfig if hosted in Kubernetes
  • warning - Warning jq query which returns [true/false]
  • critical - Critical jq query which returns [true/false]

The following keys are supported for Secret passed via secretName flag.

USERNAMEOptional Username used with Basic auth for HTTP URL.
PASSWORDOptional Password used with Basic auth for HTTP URL.
TOKENOptional Token used as Bearer auth for HTTP URL.
CA_CERT_DATAOptional PEM encoded CA certificate used by HTTP URL.
CLIENT_CERT_DATAOptional PEM encoded Client certificate used by HTTP URL.
CLIENT_KEY_DATAOptional PEM encoded Client private key used by HTTP URL.
INSECURE_SKIP_VERIFYOptional If set to true, skip certificate verification.

Execution of this command can result in following states:

  • OK


Before You Begin

At first, you need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. If you do not already have a cluster, you can create one by using Minikube.

Now, install Searchlight operator in your cluster following the steps here.

To keep things isolated, this tutorial uses a separate namespace called demo throughout this tutorial. Run the following command to prepare your cluster for this tutorial:

$ kubectl create namespace demo
namespace "demo" created

$ kubectl get namespaces
NAME          STATUS    AGE
default       Active    6h
kube-public   Active    6h
kube-system   Active    6h
demo          Active    4m

Check JSON response of HTTP api

In this tutorial, a ClusterAlert will be used check JSON response of a HTTP api.

$ cat ./docs/examples/cluster-alerts/json_path/demo-0.yaml

kind: ClusterAlert
  name: json-path-demo-0
  namespace: demo
  check: json_path
    critical: '.metadata.env!="prod"'
  checkInterval: 30s
  alertInterval: 2m
  notifierSecretName: notifier-config
  - notifier: Mailgun
    state: CRITICAL
    to: ["[email protected]"]
$ kubectl apply -f ./docs/examples/cluster-alerts/json_path/demo-0.yaml
clusteralert "json-path-demo-0" created

$ kubectl describe clusteralert -n demo json-path-demo-0
Name:		json-path-demo-0
Namespace:	demo
Labels:		<none>
  FirstSeen	LastSeen	Count	From			SubObjectPath	Type		Reason		Message
  ---------	--------	-----	----			-------------	--------	------		-------
  16s		16s		1	Searchlight operator			Warning		BadNotifier	Bad notifier config for ClusterAlert: "json-path-demo-0". Reason: secrets "notifier-config" not found
  16s		16s		1	Searchlight operator			Normal		SuccessfulSync	Applied ClusterAlert: "json-path-demo-0"

Voila! json_path command has been synced to Icinga2. Please visit here to learn how to configure notifier secret. Now, open IcingaWeb2 in your browser. You should see a Icinga host demo@cluster and Icinga service json-path-demo-0.


Cleaning up

To cleanup the Kubernetes resources created by this tutorial, run:

$ kubectl delete ns demo

If you would like to uninstall Searchlight operator, please follow the steps here.

Next Steps

  • To periodically run various checks on nodes in a Kubernetes cluster, use NodeAlerts.
  • To periodically run various checks on pods in a Kubernetes cluster, use PodAlerts.
  • See the list of supported notifiers here.
  • Wondering what features are coming next? Please visit here.
  • Want to hack on Searchlight? Check our contribution guidelines.