Create Metadata Profile API
This is quick guide instructions to create metadata profiles using input JSON as follows. For a more detailed guide, see Create MetadataProfile
Request
POST /createMetadataProfile
curl -H 'Accept: application/json' -X POST --data 'copy paste below JSON' http://<URL>:<PORT>/createMetadataProfile
Example Request for profile name - `cluster-metadata-local-monitoring`
### Example Request ```json { "apiVersion": "recommender.com/v1", "kind": "KruizeMetadataProfile", "metadata": { "name": "cluster-metadata-local-monitoring" }, "profile_version": 1, "k8s_type": "openshift", "datasource": "prometheus", "query_variables": [ { "name": "namespacesAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] }, { "name": "workloadsAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] }, { "name": "containersAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (container, image, workload, workload_type, namespace) (avg_over_time(kube_pod_container_info{container!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]) * on (pod, namespace) group_left(workload, workload_type) avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] } ] } ```Response
Example Response
### Example Response ```json { "message": "Metadata Profile : cluster-metadata-local-monitoring created successfully. View all metadata profiles at /listMetadataProfiles", "httpcode": 201, "documentationLink": "", "status": "SUCCESS" } ```Invalid Scenarios:
Missing mandatory fields
Mandatory fields required to create MetadataProfile are - `apiVersion`, `kind`, `metadata`, `name`, `datasource`, `query_variables` Example: With missing profile "name" ```json { "message": "Validation failed: JSONObject[\"name\"] not found.", "httpcode": 500, "documentationLink": "", "status": "ERROR" } ```Duplicate attempt to create MetadataProfile
```json { "message": "Validation failed: Metadata Profile already exists: cluster-metadata-local-monitoring", "httpcode": 409, "documentationLink": "", "status": "ERROR" } ```Missing mandatory fields from `query_variables`
Mandatory fields of `query_variables` are - `name`, `aggregation_functions`, `function`, `query` Example: With missing "query" ```json { "message": "Validation failed: JSONObject[\"query\"] not found.", "httpcode": 500, "documentationLink": "", "status": "ERROR" } ```List Metadata Profiles API
This is quick guide instructions to retrieve metadata profiles created as follows.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | string | optional | The name of the metadata profile |
| verbose | string | optional | Flag to retrieve all the metadata queries |
Request without passing parameters
GET /listMetadataProfiles
curl -H 'Accept: application/json' http://<URL>:<PORT>/listMetadataProfiles
Returns list of all the metadata profile names created
Example Response
### Example Response ```json [ { "name": "cluster-metadata-local-monitoring" }, { "name": "bulk-cluster-metadata-local-monitoring" } ] ```Request with metadata profile name
GET /listMetadataProfiles
curl -H 'Accept: application/json' http://<URL>:<PORT>/listMetadataProfiles?name=cluster-metadata-local-monitoring
Returns metadata profile of the name specified
Example Response
### Example Response ```json [ { "apiVersion": "recommender.com/v1", "kind": "KruizeMetadataProfile", "metadata": { "name": "cluster-metadata-local-monitoring" }, "profile_version": 1, "k8s_type": "openshift", "datasource": "prometheus", "query_variables": [ { "name": "namespacesAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] }, { "name": "workloadsAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] }, { "name": "containersAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (container, image, workload, workload_type, namespace) (avg_over_time(kube_pod_container_info{container!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]) * on (pod, namespace) group_left(workload, workload_type) avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] } ] } ] ```Request
GET /listMetadataProfiles
curl -H 'Accept: application/json' http://<URL>:<PORT>/listMetadataProfiles?verbose=true
Returns list of all the metadata profile created with all the metadata queries