|
| 1 | +apiVersion: v1 |
| 2 | +kind: ConfigMap |
| 3 | +metadata: |
| 4 | + name: fluent-bit-log-collector-config-all |
| 5 | + namespace: prophecis |
| 6 | + labels: |
| 7 | + k8s-app: fluent-bit |
| 8 | +data: |
| 9 | + # Configuration files: server, input, filters and output |
| 10 | + # ====================================================== |
| 11 | + fluent-bit.conf: | |
| 12 | + [SERVICE] |
| 13 | + Flush 1 |
| 14 | + Log_Level info |
| 15 | + Daemon off |
| 16 | + Parsers_File parsers.conf |
| 17 | + HTTP_Server On |
| 18 | + HTTP_Listen 0.0.0.0 |
| 19 | + HTTP_Port 2020 |
| 20 | + @INCLUDE training-log.conf |
| 21 | + @INCLUDE record_modifier.conf |
| 22 | + @INCLUDE output-elasticsearch.conf |
| 23 | + training-log.conf: | |
| 24 | + [INPUT] |
| 25 | + Name tail |
| 26 | + Tag training.* |
| 27 | + Path /job/*.log |
| 28 | + Parser syslog |
| 29 | + DB /job/training-log.db |
| 30 | + Mem_Buf_Limit 5MB |
| 31 | + Skip_Long_Lines On |
| 32 | + Refresh_Interval 10 |
| 33 | + Key line |
| 34 | + record_modifier.conf: | |
| 35 | + [FILTER] |
| 36 | + Name lua |
| 37 | + Match training.* |
| 38 | + script training.lua |
| 39 | + call cb_print |
| 40 | + Type_int_key rindex time |
| 41 | + Match training.* |
| 42 | + [FILTER] |
| 43 | + Name nest |
| 44 | + Match training.* |
| 45 | + Operation nest |
| 46 | + Wildcard time |
| 47 | + Wildcard rindex |
| 48 | + Wildcard training_id |
| 49 | + Nest_under meta |
| 50 | + training.lua: | |
| 51 | + start_line_num = 1 |
| 52 | + function cb_print(tag, timestamp, record) |
| 53 | + fname_strat_num = string.find(tag,".training")+1 |
| 54 | + fname_end_num = string.find(tag,".",-1) |
| 55 | + fname = string.sub(tag,fname_strat_num,-5) |
| 56 | + |
| 57 | + fline_name = "/job/"..fname.."-line.pos" |
| 58 | + print(fline_name) |
| 59 | + -- check if file exists |
| 60 | + local file = io.open(fline_name, "r") |
| 61 | + -- if file not exists, create file and set default value |
| 62 | + if(file == nil) |
| 63 | + then |
| 64 | + print("file not exists") |
| 65 | + file = io.open(fline_name, "w+") |
| 66 | + file:write(start_line_num) |
| 67 | + end |
| 68 | + file:close() |
| 69 | + -- read current line num from line.pos |
| 70 | + file = io.open(fline_name, "r") |
| 71 | + local current = file:read() |
| 72 | + file:close() |
| 73 | + -- object which will be returned |
| 74 | + new_record = {} |
| 75 | + new_record["training_id"] = fname |
| 76 | + -- line num |
| 77 | + new_record["rindex"] = tonumber(current) |
| 78 | + |
| 79 | + fname_strat_num = string.find(tag,".training")+1 |
| 80 | + fname_end_num = string.find(tag,".",-1) |
| 81 | + fname = string.sub(tag,fname_strat_num,-5) |
| 82 | + new_record["training_id"] = fname |
| 83 | +
|
| 84 | + -- current timestamp |
| 85 | + origin_time = string.format("%d", timestamp*1000) |
| 86 | + -- new_record["time"] = string.sub(origin_time,1,-8) |
| 87 | + new_record["time"] = tonumber(origin_time) |
| 88 | + -- other key from input |
| 89 | + for key, val in pairs(record) do |
| 90 | + new_record[key] = val |
| 91 | + end |
| 92 | + -- save back in line.pos |
| 93 | + file = io.open(fline_name, "w+") |
| 94 | + current = current + 1 |
| 95 | + file:write(current) |
| 96 | + file:close() |
| 97 | + return 1, timestamp, new_record |
| 98 | + end |
| 99 | + output-elasticsearch.conf: | |
| 100 | + [OUTPUT] |
| 101 | + Name es |
| 102 | + Match * |
| 103 | + Host ${FLUENT_ELASTICSEARCH_HOST} |
| 104 | + Port ${FLUENT_ELASTICSEARCH_PORT} |
| 105 | + HTTP_User ${FLUENT_ELASTICSEARCH_USER} |
| 106 | + HTTP_Passwd ${FLUENT_ELASTICSEARCH_PASSWD} |
| 107 | + Index dlaas_learner_data |
| 108 | + #Logstash_Format On |
| 109 | + Replace_Dots On |
| 110 | + Retry_Limit False |
| 111 | + Type logline |
| 112 | + # Time_Key time |
| 113 | +
|
| 114 | + [OUTPUT] |
| 115 | + Name stdout |
| 116 | + Match * |
| 117 | +
|
| 118 | +
|
| 119 | + parsers.conf: | |
| 120 | + [PARSER] |
| 121 | + Name apache |
| 122 | + Format regex |
| 123 | + Regex ^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*?)(?: +\S*)?)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$ |
| 124 | + Time_Key time |
| 125 | + Time_Format %d/%b/%Y:%H:%M:%S %z |
| 126 | +
|
| 127 | + [PARSER] |
| 128 | + Name apache2 |
| 129 | + Format regex |
| 130 | + Regex ^(?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$ |
| 131 | + Time_Key time |
| 132 | + Time_Format %d/%b/%Y:%H:%M:%S %z |
| 133 | +
|
| 134 | + [PARSER] |
| 135 | + Name apache_error |
| 136 | + Format regex |
| 137 | + Regex ^\[[^ ]* (?<time>[^\]]*)\] \[(?<level>[^\]]*)\](?: \[pid (?<pid>[^\]]*)\])?( \[client (?<client>[^\]]*)\])? (?<message>.*)$ |
| 138 | +
|
| 139 | + [PARSER] |
| 140 | + Name nginx |
| 141 | + Format regex |
| 142 | + Regex ^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*?)(?: +\S*)?)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")?$ |
| 143 | + Time_Key time |
| 144 | + Time_Format %d/%b/%Y:%H:%M:%S %z |
| 145 | +
|
| 146 | + [PARSER] |
| 147 | + Name json |
| 148 | + Format json |
| 149 | + Time_Key time |
| 150 | + Time_Format %d/%b/%Y:%H:%M:%S %z |
| 151 | +
|
| 152 | + [PARSER] |
| 153 | + Name docker |
| 154 | + Format json |
| 155 | + Time_Key time |
| 156 | + Time_Format %Y-%m-%dT%H:%M:%S.%L |
| 157 | + Time_Keep On |
| 158 | +
|
| 159 | + [PARSER] |
| 160 | + Name syslog |
| 161 | + Format regex |
| 162 | + Regex ^\<(?<pri>[0-9]+)\>(?<time>[^ ]* {1,2}[^ ]* [^ ]*) (?<host>[^ ]*) (?<ident>[a-zA-Z0-9_\/\.\-]*)(?:\[(?<pid>[0-9]+)\])?(?:[^\:]*\:)? *(?<message>.*)$ |
| 163 | + # Time_Format %b %d %H:%M:%S |
| 164 | + Time_Format %S%L |
| 165 | + Time_Keep On |
0 commit comments