Function Creation
Configuring Functions
A Function is a configuration that ties signals from a Sensor to a Rule, along with the ability to enrich metadata tags on the received signals.
A Function is defined to be a part of an "Aspect" and is configured to have a base weight (scale of 1 to 10).
Sample Fitness Function
{
"kind": "FitnessFunction",
"apiVersion": "fitness.orcasio.com/v1alpha3",
"metadata": {
"name": "avail-deploy-sample_tenant",
"namespace": "sample_tenant"
},
"spec": {
"sensor": "sensor://fitness.orcasio.net/kubernetes",
"source": "deployment",
"filters": {
".data.kind": "Deployment"
},
"aspect": "Availability",
"weight": 8,
"rule": "avail-deploy",
"enabled": true,
"dryrun": false,
"tags": {
"app": ".metadata.name",
"name": ".metadata.name",
"namespace": ".metadata.namespace"
}
}
}
kind: FitnessFunction
apiVersion: fitness.orcasio.com/v1alpha3
metadata:
name: avail-deploy-sample_tenant
namespace: <tenant_ID>
spec:
sensor: sensor://fitness.orcasio.net/kubernetes
source: deployment
filters:
".data.kind": Deployment
aspect: Availability
weight: 8
rule: avail-deploy
enabled: true
dryrun: false
tags:
app: ".metadata.name"
name: ".metadata.name"
namespace: ".metadata.namespace"
Function Specification
| Name | Description | Value | Value Type |
|---|---|---|---|
| kind | Configuration object kind | FitnessFunction | (fixed - do not change) |
| apiVersion | Configuration object version | fitness.orcasio.com/v1alpha3 | (fixed - do not change) |
| metadata.name | Unique name of function | \<unique string> | Ensure name is unique and no spaces or special chars except for "-" |
| metadata.namespace | Unique namespace corresponding to the tenant | \<unique string> | (fixed - do not change) |
| spec.sensor | Sensor from which to source the signals | sensor:\/\/\<sensor name> | ex: sensor:\/\/fitness.orcasio.net/kubernetes |
| spec.source | Name to uniquely identify the source of the metric | \<string> | ex: deployment |
| spec.filters* | (Optional) Allows for signals to be filtered before scoring | -empty- | Filters can be written as JSON query path at a level below the "spec.filters" as in example: .data.kind: Deployment |
| spec.aspect | Aspect name to group functions under | \<string> | Ex: "Security", "Architecture", "Splunk Enablement", etc. |
| spec.weight | Relative weight of this function to other functions in the same "Aspect" | \<integer from 1-10> | Ex: 8 |
| spec.rule | Rule name to process the metric against to calculate the score | \<valid rule name string> | Reference the name of the Fitness Rule here - convention is to use the same name as Fitness Function |
| spec.enabled | Indicates if a Function is enabled to process signals or disabled | true / false | ex: true |
| spec.dryrun | Indicates if the calculated score contributes to the overall score (false) or if its used to test functions for new scenarios (true) | true / false | ex: false |
| spec.tags | Tags to replace/enrich the metadata tags from Sensor Signals | -empty- | Provide key: value pairs as an array to enrich the tag data as a level below spec.tags . The "value" can be derived as a json query path from the incoming metric data or a static value. |
Configure Function Using API
API Usage:
- URI: (api-URL)/api/inventory/v1alpha3/fitnessfunctions/<name_of_function>
- Method: PUT ( this is Create or Update a Fitness Function)
- Header (for security): orcas-token: TOKEN (See TOKEN generation details above)
- Header: Content-type: application/json
-
Request Body (JSON):
{ "data": { "kind": "FitnessFunction", "apiVersion": "fitness.orcasio.com/v1alpha3", "metadata": { "name": "avail-deploy-sample_tenant", "namespace": "sample_tenant" }, "spec": { "sensor": "sensor://fitness.orcasio.net/kubernetes", "source": "deployment", "filters": { ".data.kind": "Deployment" }, "aspect": "Availability", "weight": 8, "rule": "avail-deploy", "enabled": true, "dryrun": false, "tags": { "app": ".metadata.name", "name": ".metadata.name", "namespace": ".metadata.namespace" } } } }
- Header: Content-type: application/x-yaml
-
Request Body (raw-text):
data: kind: FitnessFunction apiVersion: fitness.orcasio.com/v1alpha3 metadata: name: avail-deploy-sample_tenant namespace: sample_tenant spec: sensor: sensor://fitness.orcasio.net/kubernetes source: deployment filters: ".data.kind": Deployment aspect: Availability weight: 8 rule: avail-deploy enabled: true dryrun: false tags: app: ".metadata.name" name: ".metadata.name" namespace: ".metadata.namespace"
-
Request Response:
{ "data": [ { "apiVersion": "fitness.orcasio.com/v1alpha3", "kind": "FitnessFunction", "metadata": { "creationTimestamp": "2023-01-19T17:43:30Z", "generation": 3, "name": "avail-deploy", "namespace": "sample_tenant", "resourceVersion": "525248586", "uid": "61729ac8-84d4-474b-9262-134cde73cfa0" }, "spec": { "aspect": "Availability", "dryrun": false, "enabled": true, "filters": { ".data.kind": "Deployment" }, "rule": "avail-deploy", "sensor": "sensor://fitness.orcasio.net/kubernetes", "source": "deployment", "tags": { "app": ".metadata.name", "name": ".metadata.name", "namespace": ".metadata.namespace" }, "weight": 8 }, "status": { "state": "enabled" } } ] }{ "error": "the server rejected our request due to an error in our request", "message": { "apiVersion": "v1", "code": 422, "details": { "causes": [ { "field": "metadata.resourceVersion", "message": "Invalid value: 0x0: must be specified for an update", "reason": "FieldValueInvalid" } ], "group": "fitness.orcasio.com", "kind": "fitnessfunctions", "name": "avail-deploy" }, "kind": "Status", "message": "fitnessfunctions.fitness.orcasio.com \"avail-deploy\" is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update", "metadata": {}, "reason": "Invalid", "status": "Failure" } }