Logstash 配置,"if string contains..."
Logstash config, "if string contains..."
那么,假设我有一部分日志行看起来像这样:
GET /restAPI/callMethod1/8675309
GET匹配一个http方法,get被提取,其余匹配一个URI,也被提取。现在在 logstash 配置中,假设我想做这样的事情...
if [METHOD] == "GET" {
if [URI] (CONTAINS <--Is there a way to do this?) =="restAPI/callMethod1"{
....
有什么办法吗?如果是这样,我该怎么做?
谢谢
您可以像这样使用 =~
(正则表达式)运算符简单地实现它(参见 conditionals):
if [METHOD] == "GET" {
if [URI] =~ /restAPI\/callMethod1/ {
...
那么,假设我有一部分日志行看起来像这样:
GET /restAPI/callMethod1/8675309
GET匹配一个http方法,get被提取,其余匹配一个URI,也被提取。现在在 logstash 配置中,假设我想做这样的事情...
if [METHOD] == "GET" {
if [URI] (CONTAINS <--Is there a way to do this?) =="restAPI/callMethod1"{
....
有什么办法吗?如果是这样,我该怎么做?
谢谢
您可以像这样使用 =~
(正则表达式)运算符简单地实现它(参见 conditionals):
if [METHOD] == "GET" {
if [URI] =~ /restAPI\/callMethod1/ {
...