Download Control Changes
Available Guides
Reference:
| Field | Description |
|---|---|
| id | A unique random generated UUID as the key id for the Control Change. |
| resource | Asset / Data Stream pair in KRN format. The KRN format is krn:ad:<asset_name>/<data_stream_name> |
| last_state | The current state of the Control Change (pending, ready, sent, applied, failed) |
| last_message | The message attached to the current state of the Control Change |
| created_type | What type of process created the Control Change |
| created_by | Name of the process that created the Control Change |
| old_payload | Original value of resource before new value is applied |
| payload | New value to write to resource |
| timestamp | Exact UTC time when the data value was recorded, formatted in ISO 8601. |
| created | UTC time when the Control Change was created, formatted in ISO 8601. |
| updated | UTC time when any Control Change values were last updated, formatted in ISO 8601. |
| status_log | An array of objects for the time of each action taken by the Control Change and its related information |
Download Control Changes for an Asset
In this example we will get all the Control Changes that were applied in a 24 hour period for an Asset / Data Stream pair. The Asset name is pcp_01.
It is not possible export control change range from Kelvin UI.
curl -X "POST" \
"https://<url.kelvin.ai>/api/v4/control-changes/range/get" \
-H "Authorization: Bearer <Your Current Token>" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"start_date": "2024-05-06T12:00:00.000Z",
"end_date": "2024-08-07T12:00:00.000Z",
"resources": [
"krn:ad:pcp_01/speed_sp"
],
"states": [
"applied"
]
}'
You will receive a response body with a status code of 200, indicating a successful operation.
For example, the response body might look like this:
{
"pagination": {
"next_page": "W3siS2V5IjoiaWQiLCJWYWx1ZSI6IjA0NTZjMzM1LTM2NTctNGMxMS04Y2NmLWUxOWY1NTYxNTIyOCJ9XQ==",
"previous_page": null
},
"data": [
{
"id": "000e0322-42f5-443b-aa76-2028ea1dd7c0",
"resource": "krn:ad:pcp_01/speed_sp",
"last_state": "applied",
"last_message": "Verified after 0.46 seconds.",
"created_type": "workload",
"created_by": "sales-01-cluster/pcp-optimization-d2tmv6s14vzz:pcp-optimization/1.0.202403041506",
"payload": 66,
"timestamp": "2024-07-24T07:01:50.745748Z",
"created": "2024-07-24T07:01:51.409316Z",
"updated": "2024-07-24T07:01:51.352865Z",
"status_log": [
{
"timestamp": "2024-07-24T07:01:51.352865Z",
"state": "applied",
"message": "Verified after 0.46 seconds.",
"reported": {
"before": {
"value": 60,
"timestamp": "2024-07-24T07:01:48.226849Z",
"source": "ccm"
},
"after": {
"value": 66,
"timestamp": "2024-07-24T07:01:51.088854Z",
"source": "ccm"
}
}
},
{
"timestamp": "2024-07-24T07:01:50.896234Z",
"state": "sent",
"message": "The Control Change was sent to the Bridge."
}
],
"reported": {
"before": {
"value": 60,
"timestamp": "2024-07-24T07:01:48.226849Z",
"source": "ccm"
},
"after": {
"value": 66,
"timestamp": "2024-07-24T07:01:51.088854Z",
"source": "ccm"
}
},
"expiration_date": "2024-07-24T15:01:50.744795Z"
},
{
"id": "00139a71-b58f-41e8-9772-67234557f6c7",
"resource": "krn:ad:pcp_01/speed_sp",
"last_state": "applied",
"last_message": "Verified after 1.31 seconds.",
"created_type": "workload",
"created_by": "sales-01-cluster/pcp-optimization-d2tmv6s14vzz:pcp-optimization/1.0.202403041506",
"payload": 54,
"timestamp": "2024-07-19T21:22:23.269812Z",
"created": "2024-07-19T21:22:24.642944Z",
"updated": "2024-07-19T21:22:24.615134Z",
"status_log": [
{
"timestamp": "2024-07-19T21:22:24.615134Z",
"state": "applied",
"message": "Verified after 1.31 seconds.",
"reported": {
"before": {
"value": 60,
"timestamp": "2024-07-19T21:22:18.426532Z",
"source": "ccm"
},
"after": {
"value": 54,
"timestamp": "2024-07-19T21:22:24.084406Z",
"source": "ccm"
}
}
},
{
"timestamp": "2024-07-19T21:22:23.315138Z",
"state": "sent",
"message": "The Control Change was sent to the Bridge."
}
],
"reported": {
"before": {
"value": 60,
"timestamp": "2024-07-19T21:22:18.426532Z",
"source": "ccm"
},
"after": {
"value": 54,
"timestamp": "2024-07-19T21:22:24.084406Z",
"source": "ccm"
}
},
"expiration_date": "2024-07-20T05:22:23.257394Z"
}
]
}
from kelvin.api.client import Client
# Login
client = Client(config={"url": "https://<url.kelvin.ai>", "username": "<your_username>"})
client.login(password="<your_password>")
# Get Range of Control Changes
response = client.control_change.get_control_change_range(
data={
"start_date": "2024-05-06T12:00:00.000Z",
"end_date": "2024-08-07T12:00:00.000Z",
"resources": [
"krn:ad:pcp_01/speed_sp"
],
"states": [
"applied"
]
}
)
# Convert the response into a Pandas DataFrame
df = response.to_df()
# Print the result
print(df)
You will receive a response like this:
timestamp resource payload last_state
0 2024-07-24 07:01:50.745748+00:00 krn:ad:pcp_01/speed_sp 66.0 applied
1 2024-07-19 21:22:23.269812+00:00 krn:ad:pcp_01/speed_sp 54.0 applied
2 2024-07-27 18:27:56.478093+00:00 krn:ad:pcp_01/speed_sp 66.0 applied
3 2024-08-01 08:44:24.912824+00:00 krn:ad:pcp_01/speed_sp 66.0 pending
4 2024-07-25 18:17:23.417537+00:00 krn:ad:pcp_01/speed_sp 54.0 applied
5 2024-08-03 12:00:06.965508+00:00 krn:ad:pcp_01/speed_sp 66.0 pending
6 2024-07-29 13:28:30.807431+00:00 krn:ad:pcp_01/speed_sp 60.5 applied
7 2024-07-26 21:42:39.893841+00:00 krn:ad:pcp_01/speed_sp 54.0 applied
8 2024-08-06 04:45:55.671779+00:00 krn:ad:pcp_01/speed_sp 54.0 pending
9 2024-07-13 05:50:15.592659+00:00 krn:ad:pcp_01/speed_sp 54.0 applied