大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
成都创新互联公司是一家专注于网站设计、成都网站制作与策划设计,明山网站建设哪家好?成都创新互联公司做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:明山等地区。明山做网站价格咨询:13518219792
error_reporting( E_ALL&~E_NOTICE );
define('ELK_QUERY_RR_QUERY', '{
"query": {
"filtered": {
"query": {
"query_string": {
"analyze_wildcard": true,
"query": "type:phptestkv AND report_type:\"paycenter.dopayment\""
}
},
"filter": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-15m"
}
}
}
],
"must_not": []
}
}
}
},
"size": 0,
"aggs": {
"1": {
"terms": {
"field": "success",
"size": 5,
"order": {
"_count": "desc"
}
}
}
}
}
}');
define('ELK_QUERY_RR_URL', 'http://localhost:9200/logstash-phptest-*/_search?search_type=count&pretty');
function curl_post($url, $content, $header=''){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$tmpInfo = curl_exec($curl);
if (curl_errno($curl))
{
print("[error] CURL ERROR: ".curl_error($curl)."\r\n");
}
curl_close($curl);
return $tmpInfo;
}
function Query_Curl(){
$request_params_rr_query = ELK_QUERY_RR_QUERY;
$rr_target =curl_post(ELK_QUERY_RR_URL, $request_params_rr_query, 'Authorization:Basic bmVpZ291OjE5dkpDYzdCUUltbw==');
return get_rr_value($rr_target);
}
function get_rr_value($results){
$results_object = json_decode($results, true);
return $results_object;
}
function query(){
$result=Query_Curl();
$doc_count=$result['aggregations']['1']['buckets'][0]['doc_count'];
$total=$result['hits']['total'];
$ratio=0;
if($total>=5){
if($doc_count && $total){
$ratio=round($doc_count/$total, 2);
}
if($result['aggregations']['1']['buckets'][0]['key']==1){
if($ratio){
$ratio=1-($ratio);
}
}
}
return $ratio;
}
$ratio=query();
echo $ratio;
?>