timestamp 구문 분석기는 필드를 생성하지는 않지만 대신 문자열의 입력을 내부 타임 스탬프 형식(UNIX epoch 시작인 1970년 1월 1일(UTC/GMT 자정) 이후의 시간을 밀리초로 표시)으로 변환합니다.
유일하게 지원되는 구성 옵션은 format입니다. 예를 들면 format=%Y-%m-%d %H:%M:%S입니다.
CLF 구문 분석기와 달리 timestamp 구문 분석기는 %A%B%d%H%M%S%Y%z와 같이 시간 지정자 사이에 구분 기호가 없을 때 시간을 구문 분석할 수 있습니다.
timestamp 구문 분석기가 사용하는 형식 지정자는 다음과 같습니다.
'%a': Abbreviated weekday name, for example: Thu
'%A': Full weekday name, for example: Thursday
'%b': Abbreviated month name, for example: Aug
'%B': Full month name, for example: August
'%d': Day of the month, for example: 23. strftime() expects zero-padded (01-31) digits
for this specifier but Log Insight agents can parse space-padded and non-padded
day numbers, too.
'%e': Day of the month, for example: 13. strftime() expects space-padded ( 1-31) digits
for this specifier but Log Insight agents can parse zero-padded and non-padded
day numbers too.
'%f': Fractional seconds of time, for example: .036 'f' specifier assumes that '.' or ','
character should exist before fractional seconds and there is no need to mention
that character in the format. If none of these characters precedes fractional seconds,
timestamp wouldn't be parsed.
'%H': Hour in 24h format (00-23), for example: 14. Zero-padded, space-padded, and non-padded hours
are supported.
'%I': Hour in 12h format (01-12), for example: 02. Zero-padded, space-padded and non-padded hours
are supported.
'%m': Month as a decimal number (01-12), for example: 08. Zero-padded, space-padded
and non-padded month numbers are supported.
'%M': Minute (00-59), for example: 55
'%p': AM or PM designation, for example: PM
'%S': Second (00-61), for example: 02
'%s': Total number of seconds from the UNIX epoch start, for example 1457940799
(represents '2016-03-14T07:33:19' timestamp)
'%Y': Year, for example: 2001
'%z': ISO 8601 offset from UTC in timezone (1 minute=1, 1 hour=100)., for example: +100
추가적인 지정자는 타임 스탬프 구문 분석기에 서 수락되지만 해당 값은 무시되며 구문 분석된 시간에 영향을 미치지 않습니다.
'%C': Year divided by 100 and truncated to integer (00-99), for example: 20 '%g': Week-based year, last two digits (00-99), for example, 01 '%G': Week-based year, for example, 2001 '%j': Day of the year (001-366), for example: 235 '%u': ISO 8601 weekday as number with Monday as 1 (1-7), for example: 4 '%U': Week number with the first Sunday as the first day of week one (00-53), for example: 33 '%V': ISO 8601 week number (00-53), for example: 34 '%w': Weekday as a decimal number with Sunday as 0 (0-6), for example: 4 '%W': Week number with the first Monday as the first day of week one (00-53), for example: 34 '%y': Year, last two digits (00-99), for example: 01
format 매개 변수가 정의되지 않은 경우 Timestamp 구문 분석기는 기본 형식을 사용하여 타임 스탬프를 구문 분석합니다.
자동 타임 스탬프 구문 분석기
자동 타임 스탬프 구문 분석기는 타임 스탬프 구문 분석기에 대해 정의된 형식이 없는 경우 호출되거나
field_decoder에서
timestamp를 사용하여 타임 스탬프 구문 분석기 정의 없이 직접 구문 분석기를 호출할 수 있습니다. 예:
[parser|mycsv]
base_parser=csv
debug=yes
fields=timestamp,action,source_id,dest
field_decoder={"timestamp": "timestamp"}
기본 구성을 사용하는 타임 스탬프 구문 분석기
이 예에서는 기본 구성을 사용하는 timestamp 구문 분석기를 보여줍니다.
[parser|tsp_parser] base_parser=timestamp debug=no format=%Y-%m-%d %H:%M:%S%f
timestamp 구문 분석기를 다른 구문 분석기(예: CSV 구문 분석기)와 통합하려면 다음 구성을 지정하십시오.
[parser|mycsv]
base_parser=csv
fields=timestamp,action,source_id,dest
field_decoder={"timestamp": "tsp_parser"}
이 구성이 정의되면 mycsv 구문 분석기는 구성에 지정된 이름의 필드를 추출하고 timestamp 필드의 내용에 대해 tsp_parser를 실행합니다. tsp_parser가 유효한 타임 스탬프를 검색하면 서버는 로그 메시지에 해당 타임 스탬프를 사용합니다.