How to Report Custom Advanced Functions with Local Func¶
If you want to use locally configured functions in Time Series Graph > Advanced Functions, you need to create a Guance connector after setting up the local function script in the local Func. Once synchronized and published, you can use the custom advanced functions.
Specific Operations¶
Step One: Create a Guance Connector¶
Refer to Create Guance Connector
Step Two: Write Advanced Functions¶
Create a new local function script in Func. The example algorithm is as follows:
'''
Example Algorithm for Advanced Functions
Example processing content:
1. Data input through DQL statement
2. Return the result after algorithm processing
Note:
The entry function for the algorithm must be `AlgorithmScriptName(data,**kwargs)`
`data` is the structure of 'series' inside the data queried by DQL, for example:
[
{
'name': 'cpu',
'tags': {'image': 'nginx'},
'columns': ['usage_total', 'last'],
'values': [[1681200000000, 8],[1681202880000, 23],......]
}
...
]
**kwargs are optional parameters for the algorithm
Entry function: DBSCAN(data,eps)
Output example:
[
{
'status' : "abnormal_series",
# Marks whether this time series data is normal or an outlier. Outliers have a status of "abnormal_series", while normal data has a status of "normal_series"
'name' : 'cpu',
"tags" : {'image': 'nginx'},
'colums' : ['usage_total', 'last'],
"values" : [[1681274880000,8],[1681277760000,20],……],
},
...
]
'''
After writing the function, add the category type. The user-defined category format is as follows:
Warning
Don't forget to publish after completing the code writing!!!
Step Three: Use Local Functions¶
After completing the above steps, the custom advanced functions will be added to the Guance workspace. In Guance Scenarios, when Creating a Dashboard, add a Time Series Graph. You can see the local functions under Advanced Functions as shown in the figure:
Step Four: Display Style¶
- Configuration effect with outliers:
- If there are no outliers, the original data is displayed on the frontend: