我正在使用logstash 1.4.2,
{
"network": {
"servers": [ "xxx.xxx.xxx.xxx:5000" ],
"timeout": 15,
"ssl ca": "certs/logstash-forwarder.crt"
},
"files": [
{
"paths": [ "/var/log/messages" ],
"fields": { "type": "syslog" }
},
{
"paths": [ "/var/log/secure" ],
"fields": { "type": "linux-syslog" }
}
]
}
Run Code Online (Sandbox Code Playgroud)
================================================== =======
在logstash服务器中
filter {
if [type] == "syslog" {
date {
locale => "en"
match => ["syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]
timezone => "Asia/Kathmandu"
target => "@timestamp"
add_field => { "debug" => "timestampMatched"} …Run Code Online (Sandbox Code Playgroud) 我已经定义了如下的dict:
a = { "b" : [20,40,45]}
Run Code Online (Sandbox Code Playgroud)
该命令a['b']将打印所有值,如下所示
[20, 40, 45]
Run Code Online (Sandbox Code Playgroud)
.我只想要一个价值.如何在值中获得b的单个值?我要做什么打印让我们说45?
我现在能做的是:
d = a['b']
print d[2]
Run Code Online (Sandbox Code Playgroud)
如何在一行中完成?