2017-11-07 1 views
0

koacacitor를 사용하여 telegraf에서 데이터를 집계하기 전에 해당 데이터를 influxdb에 집계하고 몇 백분위 수를 계산해야합니다. 그래서 나는, 내가 50 백분위 수에 대해서만 값을 가지고 있고, 나는 내 평가에서 "백분위 수"를 사용하기 때문에 나는 그와 함께 놀라게하고 있지 않다하지만 여전히, 내가 찾을 수없는 내 데이터베이스에서 테스트다중 백분위 수를 사용하는 Kapacitor 작업

var firstPerc = stream 
    |from() 
     .measurement('my_tmp_measurement_from_telegraf') 
var secondPerc = stream 
    |from() 
     .measurement('my_tmp_measurement_from_telegraf') 
firstPerc 
    |join(secondPerc) 
     .as('fp', 'sp') 
     |percentile('fp.myAggVal', 50.0) 
     |eval(lambda: "percentile") 
      .as('50p') 
     |percentile('sp.myAggVal', 90.0) 
     |eval(lambda: "percentile") 
      .as('90p') 
     |window() 
      .period(60s) 
      .every(60s) 
      .align() 
     |influxDBOut() 
      .database('myDBInInflux') 
      .retentionPolicy('autogen') 

에 대한 간단한 진드기를 썼다 Kapacitor 문서에서 필요한 결과를 얻는 방법에 대한 단서.

time 50p 90p someOtherP's otherDataICanPropablyHandle 

HALP : 여기

당신은 내가 갈망 "시각적"결과가!

답변

0

동일한 측정 스트림 (및 동일한 데이터)을 두 번 사용하므로 데이터가 팝됩니다. 먼저 측정 스트림을 저장해야합니다.

var myStream = stream 
    |from() 
     .measurement('my_tmp_measurement_from_telegraf') 

다음은 저장된 측정 값을 사용하여 스트림을 정의합니다. 현재 위치 등 적절한 그룹화, 평가를 정의한다 :

var firstPerc = myStream 
    |percentile('myAggVal', 50.0) 
    |eval(lambda: "percentile") 
     .as('percentile') 
    |window() 
     .period(60s) 
     .every(60s) 
     .align() 
var secondPerc = myStream 
    |percentile('myAggVal', 90.0) 
    |eval(lambda: "percentile") 
     .as('percentile') 
    |window() 
     .period(60s) 
     .every(60s) 
     .align() 

를 마침내, 그것은 스트림 조인을 정의하는 시간 :

var joinedStreams = firstPerc 
    |join(secondPerc) 
     .as('50', '90') 
     .tolerance(1s) 
     .streamName('measurementName') 
     |influxDBOut() 
      .database('myDBInInflux') 
      .retentionPolicy('autogen') 
      .create() 

출력 : 난 강력하게 사용하는 것이 좋습니다

time    50.percentile 90.percentile 

합니다. 허용 오차()는 동일한 공차 기간 내에 측정을 그룹화합니다.

관련 문제