$actor = "gituser" や $repo = "gituser/logstashreppo" のように "actor":"githubuser" を割り当てようとしています。変数に割り当てられた値を取得すると、ここにコピーされた exec 関数を使用してスクリプトを実行できます。あなたの考えを共有してください
全体の出力は
{
_index: "logstash-2014.11.20",
_type: "syslog",
_id: "76ggV_gfWS5u2L9rcMNCWaQ",
_score: 0.35005248,
_source: {
message: "github_audit: {"actor_ip":"192.168.1.1","from":"repositories#create","actor":"gituser","repo":"gituser/logstashreppo","action":"staff.repo_route","created_at":1236483708817,"repo_id":44758,"actor_id":1033,"data":{"actor_location":{"location":{"lat":null,"lon":null}}}}",
@version: "1",
@timestamp: "2014-11-17T11:41:50.142Z",
host: "192.168.1.1",
type: "syslog",
syslog5424_pri: "190",
timestamp: "Nov 17 03:41:50",
actor_ip: "192.168.1.1",
from: "repositories#create",
actor: "gituser",
repo: "gituser/logstashrepo",
action: "staff.repo_route",
created_at: 1236483708817,
repo_id: 44758,
actor_id: 1033,
data: {
actor_location: {
location: {
lat: null,
lon: null
}
}
}
}
}
、
私の設定ファイルは次のとおりです。
filter {
grok {
match => [
"message",
"%{SYSLOG5424PRI}%{SYSLOGTIMESTAMP:timestamp} %{HOSTNAME:host} %{GREEDYDATA:message}"
]
overwrite => ["host", "message"]
}
if [message] =~ /^git_audit: / {
grok {
match => ["message", "^git_audit: %{GREEDYDATA:json_payload}"]
}
json {
source => "json_payload"
remove_field => "json_payload"
}
mutate {
rename => ["[json][repo]", "repo"]
remove_field => "json"
}
}
}
input {
exec {
type => "audit-log"
command => "perl test.pl $actor"
}
}
output {
elasticsearch { host => localhost }
stdout { codec => rubydebug }
}