Deploying a Custom REST API Sensor
This guide will walk through the steps to install and configure a sensor deployment to collect metrics from and internal system and publish the metrics to the client tenant running in cloud.
Pre-Requisites
Follow the guide for Common Pre-requisites to complete the pre-requisites for deploying a sensor.
How it works
The Custom REST API sensor can pull data in JSON format from any REST enabled system on a timer schedule and publish the collected data as a Signal to the Pulse Platform tenant using a HTTP stream publish.
Configuration
Copy the following yaml file and make changes for all the TODO sections below:
kind: FitnessSensor
apiVersion: fitness.orcasio.com/v1alpha3
metadata:
name: turtles-all-the-way
namespace: <tenant_ID>
spec:
sensor: sensor://fitness.orcasio.net/http
source: sample_tenant-inventory
enabled: true
data:
## TODO - every 5 minutes
schedule: "0 0/5 * * * *"
host: <api-URL>
verb: GET
pathPrefix: api/inventory
token:
key: orcas-token
# TODO - GENERATE A TOKEN TO USE
value: TOKEN
# headers:
# - key: key1
# value: value
# - key: key2
# value: value
endpoints:
- name: "sensor-kube-deploy"
queryPath: "v1alpha2/fitnesssensors/kube-deploy"
# queryParams: """
# body: |
# {
# "data": {
# "spec": {
# "enabled": false
# }
# }
# }
tags:
env: dev
org: it
vertical: it
clustername: flukes
# transformer: |
# golang
# response := make(map[string]interface{})
# transcode(request, &response)
# delete(response, "metadata")
# return response, nil
# transformer: |
# // webhook
# url: http://localhost:8090/webhook
Custom REST API Sensor Configuration
As shown in the sample the configuration for a Fitness Sensor is done using a Kubernetes CRD object. This specification is picked up by the Pulse Sensor Deployment and the deployment runs the sensor on a time basis to fetch the data and publish to the remote tenant as a stream over HTTP.
Sensor Specification
| Name | Description | Value | Value Type |
|---|---|---|---|
| kind | Configuration object kind | FitnessSensor | (fixed - do not change) |
| apiVersion | Configuration object version | fitness.orcasio.com/v1alpha3 | (fixed - do not change) |
| metadata.name | Unique name of sensor | \<unique string> | Ensure name is unique and no spaces or special chars except for "-" |
| spec.sensor | Type of Fitness Sensor => HTTP | sensor:\/\/fitness.orcasio.net/http | (fixed - do not change to use HTTP Sensor) |
| spec.source | Specify Source Name to identify System/Platform/Tool | \<string> | ex: "sample_tenant-inventory" |
| spec.enabled | Boolean value to specify if Sensor is enabled to collect data or not | \<true or false> | specify true to enable the sensor |
| spec.tenant | Value to specify the Pulse Platform tenant | sample_tenant | (fixed - do not change) |
| spec.data.schedule | Cron style schedule to enable timer | (cron style schedule) | ex: "0 0/5 * * * *" specifies a 5 min timer |
| spec.data.host | REST API endpoint hostname (with optional port) | URI (http:\/\/host:port) | ex: https://api-sample_tenant.flukes.aws.orcasio.net |
| spec.data.verb | HTTP verb | Valid HTTP verbs | ex: GET |
| spec.data.pathPrefix | Path prefix for API endpoint | \<string> | ex: api/inventory |
| spec.data.token | Token key/value pair object | Object | Provide an object with key/value pair as specified in the sample |
| spec.data.headers* | (Optional) Additional header params as key/value pairs | Object Array | Provide an object with key/value pairs as specified in the sample |
| spec.data.endpoints.name | Name tag for the HTTP sensor data | \<string> | ex: "sensor-kube-deploy" |
| spec.data.endpoints.queryPath | Query to access JSON data | \<string> | ex: "v1alpha2/fitnesssensors/kube-deploy" |
| spec.tags | Object with key/value pairs to specify static tags | Object Array | For the Demo tenant vertical: \<name> is required and additional tags are encouraged |
Deploy Custom Sensor Specification
The FitnessSensor object defining the sensor configuration needs to replace the last section of the resource.yml file (FitnessSensor TODO section)
Once all other TODOs in the file are completed the configuration can be applied to a Kubernetes cluster