夜莺5.5--实现impala自动关闭waiting to be closed会话

贵有恒,何必三更起、五更眠、最无益,只怕一日曝、十日寒。这篇文章主要讲述夜莺5.5--实现impala自动关闭waiting to be closed会话相关的知识,希望能为你提供帮助。
环境CDH 5.16.2 + impala  2.12.0-cdh5.16.2
需求【夜莺5.5--实现impala自动关闭waiting to be closed会话】使用impala查询kudu数据的时候,经常会有waiting to be closed会话无法自动关闭,导致资源被占用,无法使资源最大化被利用,需要实现自动关闭已经查询完成的会话。
解决方案一、通过telegraf监控impala

[[inputs.http]]
name_override = "impala_metric"
urls = ["http://10.168.13.80:25000/queries?json","http://10.168.13.81:25000/queries?json","http://10.168.13.82:25000/queries?json","http://10.168.13.86:25000/queries?json","http://10.168.13.87:25000/queries?json"]
method = "GET"
timeout = "5s"
data_format = "json"
fielddrop = ["completed_queries_0_rows_fetched","completed_queries_10_rows_fetched","completed_queries_11_rows_fetched","completed_queries_12_rows_fetched","completed_queries_13_rows_fetched","completed_queries_14_rows_fetched","completed_queries_15_rows_fetched","completed_queries_16_rows_fetched","completed_queries_17_rows_fetched","completed_queries_18_rows_fetched","completed_queries_19_rows_fetched","completed_queries_1_rows_fetched","completed_queries_20_rows_fetched","completed_queries_21_rows_fetched","completed_queries_22_rows_fetched","completed_queries_23_rows_fetched","completed_queries_24_rows_fetched","completed_queries_2_rows_fetched","completed_queries_3_rows_fetched","completed_queries_4_rows_fetched","completed_queries_5_rows_fetched","completed_queries_6_rows_fetched","completed_queries_7_rows_fetched","completed_queries_8_rows_fetched","completed_queries_9_rows_fetched","in_flight_queries_0_rows_fetched","in_flight_queries_10_rows_fetched","in_flight_queries_11_rows_fetched","in_flight_queries_12_rows_fetched","in_flight_queries_1_rows_fetched","in_flight_queries_2_rows_fetched","in_flight_queries_3_rows_fetched","in_flight_queries_4_rows_fetched","in_flight_queries_5_rows_fetched","in_flight_queries_6_rows_fetched","in_flight_queries_7_rows_fetched","in_flight_queries_8_rows_fetched","in_flight_queries_9_rows_fetched","query_locations_0_coun","query_locations_10_count","query_locations_11_count","query_locations_12_count","query_locations_13_count","query_locations_14_count","query_locations_15_count","query_locations_16_count","query_locations_17_count","query_locations_18_count","query_locations_19_count","query_locations_1_count","query_locations_20_count","query_locations_21_count","query_locations_22_count","query_locations_23_count","query_locations_24_count","query_locations_2_count","query_locations_3_count","query_locations_4_count","query_locations_5_count","query_locations_6_count","query_locations_7_count","query_locations_8_count","query_locations_9_count"]

二、在夜莺上配置监控告警
impala_metric_num_waiting_queries > 0


三、配置自动关闭脚本
#!/usr/bin/python
#coding=utf-8
import json
import requests

ips=["localhost"]
for ip in ips:
response = json.loads(requests.get(http:// + ip + :25000/queries?json).content.decode(UTF-8))
for i in range(len(response[in_flight_queries])):
if response[in_flight_queries][i][waiting] == False:
continue
else:
query_id = response[in_flight_queries][i][query_id]
url = http:// + ip + :25000/cancel_query?query_id= +query_id
print http:// + ip + :25000/cancel_query?query_id= +query_id
requests.get(url)




    推荐阅读