자주 사용하는 쿼리 목록

개요

  • 해당 문서는 고객사 기술지원 시 자주 사용하거나 필요한 쿼리들을 정리한 가이드이며, 향후 지속적으로 업데이트 될 수 있습니다.
  • Sonar 버전에 따라 지원하지 않는 명령어가 포함될 수 있습니다.

테이블, 인덱스 별 파일 경로

인덱스

system indexes
| search table !="*sonar*" and table !="*araqne*" and table !="*sys*" and table !="*mae_*"
| fields table, base_path

테이블

system tables
| search table !="*sonar*" and table !="*araqne*" and table !="*sys*" and table !="*mae_*"
| fields table, data_path

테이블 별 원본 수집량 / 테이블 데이터 / 인덱스 데이터 / 압축률

# 테이블(수집기) 별 수집량(volume), 테이블 데이터(table_volume), 인덱스 데이터(index_volume), 로거id(logger_id)
| remote [대상 수집노드] [ system logdisk duration=[기간] 
| stats sum(disk_usage) as table_volume by table
| join type=left table [system indexdisk duration=[기간]
| stats sum(disk_usage) as index_volume by table ]]
| sort -table_volume, -index_volume
| join type=left table [remote [대상 수집노드] [table duration=[기간] sys_logger_stats
| stats sum(volume) as volume by logger_name
| rex field=logger_name "sonar_logger_(?<logger_id>\d+)"
| eval logger_id=int(logger_id)]
| join type=left logger_id [sonar loggers | fields id,table_name | rename id as logger_id, table_name as table]]
| order table,table_volume,index_volume,volume
| # 아래부터 압축률 %
| eval table_volume=table_volume/1024/1024/1024
| eval index_volume=index_volume/1024/1024/1024
| eval volume=volume/1024/1024/1024
| eval table_compressed=table_volume / volume * 100
| eval index_compressed=index_volume / volume * 100
| eval total_compressed=table_compressed+index_compressed
| # 가시성 개선
| search table !="araqne*" and table !="sys*" and table !="sonar*"
| eval table_volume=concat(round(table_volume,4),"GB")
| eval index_volume=concat(round(index_volume,4),"GB")
| eval volume=concat(round(volume,4),"GB")
| eval total_compressed=concat(round(total_compressed,3),"%")
| eval table_compressed=concat(round(table_compressed,3),"%")
| eval index_compressed=concat(round(index_compressed,3),"%")
| fields table, total_compressed, volume,table_volume, index_volume, table_compressed, index_compressed, logger_id

수집기 별 수집량

table duration=[기간] *:sys_logger_stats 
| eval logger_id =right(logger_name,5)
| join logger_id 
    [ sonar loggers 
    | eval logger_id = lpad(id,5,0) 
    | fields logger_id,name ]
| stats sum(volume) as volume by name 
| eval len_volume = len(volume)
| eval 수집용량= case(len_volume >= 0 and len_volume < 4 ,  concat(round(volume, 0) , " B"),len_volume >= 4 and len_volume < 7 ,  concat(round(volume/1024, 0) , " KB"),len_volume >= 7 and  len_volume < 10 , concat(round(volume/1024/1024, 0 ) , " MB"),len_volume >= 10 and len_volume < 13 , concat(round(volume/1024/1024/1024, 0) , " GB"),len_volume >= 13 and len_volume < 16 ,  concat(round(volume/1024/1024/1024/1024, 0) , " TB"), volume)
| fields - len_volume

날짜별 수집 용량 확인 ( 라이선스 )

system license-usages 
| eval volume=volume/1024/1024/1024 
| eval volume_GB=round(volume,3)  
| fields - count, volume

테이블 별 가장 최근/과거 로그 확인

table eachtable=t limit=10 *:[테이블 명]  // 가장 최근

table eachtable=t order=asc limit=10 *:[테이블 명]  // 가장 과거