summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryang liu <[email protected]>2024-04-10 20:02:26 +0800
committeryang liu <[email protected]>2024-04-10 20:02:26 +0800
commit36315bee31c8f273d7a77fc4871d3ca115734eb5 (patch)
tree4900f6f03736e829a849165fb47cff24de8bacf1
parentf394578198b25f26c49bb4a283def37b2479c8d1 (diff)
parent97cba73980177259f39c8d2812c41d78df5ebb69 (diff)
Merge branch 'develop' of https://git.mesalab.cn/zhaokun/tsg_policy_api into develop
-rw-r--r--getLog.py38
-rw-r--r--statistics_verify.py16
2 files changed, 36 insertions, 18 deletions
diff --git a/getLog.py b/getLog.py
index 8a991e6..1671a01 100644
--- a/getLog.py
+++ b/getLog.py
@@ -129,7 +129,7 @@ class GetLog():
metric_result = False
return metric_result
- def get_livechart_statistics(self, token, start_time, end_time, statistics_info, statistics_metircs_except, trex_ip_info, condition, host_api, vsys_id, time_granularity="PT15S", alignment_period="PT15S"):
+ def get_livechart_statistics(self, token, start_time, end_time, statistics_info, statistics_metircs_except, trex_ip_info, condition, host_api, vsys_id, alignment_period="PT1S"):
"""
:param token:
:param start_time:
@@ -140,44 +140,48 @@ class GetLog():
"""
# 请求接口查询statistics metric
headers = {'Content-Type': 'application/json', 'Authorization': token}
- url = "{}/v1/metric/query".format(host_api)
+ url = "{}/v1/log/query".format(host_api)
# 重组请求体数据
post_data_ori_json = """
{
- "exec_mode":"oneshot",
+ "execution_mode":"oneshot",
"query_type":"real_time",
- "start":"2023-11-24T02:55:40Z",
- "end":"2023-11-24T03:00:40Z",
+ "start_time":"2023-11-24T02:55:40Z",
+ "end_time":"2023-11-24T03:00:40Z",
"alignment_period":"PT15S",
"sql":"",
- "filter":"1=1",
+ "filter":"",
"template_id":1051,
"version":1,
"chart_id":2705,
"vsys_id":1,
- "rule_id":274147
+ "rule_id":274147,
+ "duration":1,
+ "interval":1,
+ "limit":10000,
+ "output_mode":"json"
}
"""
post_data_ori_dict = json.loads(post_data_ori_json)
- if statistics_info["chart_type"] == "table" or statistics_info["chart_type"] == "bar":
- dataset_identifier_name = "statistics-rule-table-or-bar-chart-template"
- elif statistics_info["chart_type"] == "line":
- dataset_identifier_name = "statistics-rule-line-chart-template"
- else: # = histogram
- dataset_identifier_name = "statistics-rule-histogram-chart-template"
- post_data_ori_dict["dataset_identifier_name"] = dataset_identifier_name
- post_data_ori_dict["start"] = start_time
- post_data_ori_dict["end"] = end_time
+ # if statistics_info["chart_type"] == "table" or statistics_info["chart_type"] == "bar":
+ # dataset_identifier_name = "statistics-rule-table-or-bar-chart-template"
+ # elif statistics_info["chart_type"] == "line":
+ # dataset_identifier_name = "statistics-rule-line-chart-template"
+ # else: # = histogram
+ # dataset_identifier_name = "statistics-rule-histogram-chart-template"
+ #post_data_ori_dict["dataset_identifier_name"] = dataset_identifier_name
+ post_data_ori_dict["start_time"] = start_time
+ post_data_ori_dict["end_time"] = end_time
post_data_ori_dict["rule_id"] = statistics_info["rule_id"]
post_data_ori_dict["template_id"] = statistics_info["template_id"]
post_data_ori_dict["chart_id"] = statistics_info["chart_id"]
post_data_ori_dict["version"] = statistics_info["version"]
- #post_data_ori_dict["time_granularity"] = time_granularity
post_data_ori_dict["alignment_period"] = alignment_period
post_data_ori_dict["vsys_id"] = vsys_id
post_data_ori_dict["sql"] =statistics_info["sql"]
# print("statistics metric请求体数据:")
#print(post_data_ori_dict)
+ #print(headers)
response = requests.post(url, json=post_data_ori_dict, headers=headers, verify=False)
#assert response.status_code == 200
r_dict = response.json()
diff --git a/statistics_verify.py b/statistics_verify.py
index 493abc1..ce71278 100644
--- a/statistics_verify.py
+++ b/statistics_verify.py
@@ -57,7 +57,21 @@ def statistic_verify(): # statistic 调试使用
statistics_bytes_distributedby_clientip.json
""".strip()
- #statistics_bytes_distributedby_clientip.json
+
+ """
+ statistics_bytes_inbytes_outbytes_distributedby_webSketchCategories
+ statistics_inbytes_distributedby_webSketchCategories
+ statistics_newC2SFlows_distributedby_webSketchCategories
+ statistics_newC2SFlows_newS2CFlows_distributedby_webSketchCategories
+ statistics_newIncomingSessions_distributedby_webSketchCategories
+ statistics_newOutgoingSessions_distributedby_webSketchCategories
+ statistics_newS2CFlows_distributedby_webSketchCategories
+ statistics_outbytes_distributedby_webSketchCategories
+ statistics_sessions_distributedby_webSketchCategories
+ statistics_sessions_newIncomingSessions_newOutgoingSessions_distributedby_webSketchCategories
+
+
+ """
#debug_json=""
print("开始...")