[SOLVED] Logstash memcached does not work as expected

Hello.
I am attempting to set a value in a memcached using logstash 7.0.1

input { stdin { } }

filter {
grok {
match => ["message", "%{GREEDYDATA:uri_fqdn}$" ]
}
fingerprint {
method => "MD5"
enable_metric => true
concatenate_sources => false
source => ["uri_fqdn"]
target => ["memcache_key"]
}
memcached {
hosts => [ "localhost:11212" ]
ttl => 3600
set => {
"%{uri_fqdn}" => "%{memcache_key}"
}
}
}

I do not see in the tcpdump that the logstash is pushing the data to the memcached instance. I only see that the session is being established when the config loads, but later it does nothing.

Anyone got it working?
My final goal is to read a file or get data from elasticsearch and load it to the memcached. Later that memcached will be used to enrich loglines.

Thanks for the help!
Regards

If you run with log.level trace do you see a TRACE message as it sets each item?

curl -XPUT '127.0.0.1:9600/_node/logging?pretty' -H 'Content-Type: application/json' -d'

{
"logger.logstash.filters.memcached" : "TRACE"
}
'
{
"host" : "logstash",
"version" : "7.0.1",
"http_address" : "127.0.0.1:9600",
"id" : "ef4c5e2a-e313-4ba1-918d-614d73ae3913",
"name" : "logstash",
"acknowledged" : true
}

I will try.

I am running now:
/usr/share/logstash/bin/logstash -f memcache_load.conf --log.level=trace

My config:
input { stdin { } }

filter {
grok {
match => ["message", "%{GREEDYDATA:uri_fqdn}$" ]
}
fingerprint {
id => "domains_set_fingerprint"
method => "MD5"
enable_metric => true
concatenate_sources => false
source => ["uri_fqdn"]
target => ["memcache_key"]
}
memcached {
id => "domains_set_memcached"
hosts => [ "localhost:11212" ]
ttl => 3600
set => {
"%{uri_fqdn}" => "%{memcache_key}"
}
}
}

output { stdout { codec => rubydebug } }

When typing in the stdin I do not see anything related to the memcached.

 org.logstash.config.ir.compiler.ComputeStepSyntaxElement@28522e30
[DEBUG] 2019-05-14 18:09:07.526 [[main]>worker14] CompiledPipeline - Compiled output
 P[output-stdout{"codec"=>"rubydebug"}|[str]pipeline:25:10:```
stdout { codec => rubydebug }
```] 
 into 
 org.logstash.config.ir.compiler.ComputeStepSyntaxElement@11d949cc
[DEBUG] 2019-05-14 18:09:07.534 [[main]>worker8] CompiledPipeline - Compiled output
 P[output-stdout{"codec"=>"rubydebug"}|[str]pipeline:25:10:```
stdout { codec => rubydebug }
```] 
 into 
 org.logstash.config.ir.compiler.ComputeStepSyntaxElement@11d949cc
[DEBUG] 2019-05-14 18:09:10.588 [pool-3-thread-3] jvm - collector name {:name=>"ParNew"}
[DEBUG] 2019-05-14 18:09:10.588 [pool-3-thread-3] jvm - collector name {:name=>"ConcurrentMarkSweep"}
[DEBUG] 2019-05-14 18:09:10.828 [logstash-pipeline-flush] PeriodicFlush - Pushing flush onto pipeline.
[DEBUG] 2019-05-14 18:09:15.594 [pool-3-thread-3] jvm - collector name {:name=>"ParNew"}
[DEBUG] 2019-05-14 18:09:15.594 [pool-3-thread-3] jvm - collector name {:name=>"ConcurrentMarkSweep"}
[DEBUG] 2019-05-14 18:09:15.828 [logstash-pipeline-flush] PeriodicFlush - Pushing flush onto pipeline.
www.google.pl[DEBUG] 2019-05-14 18:09:20.600 [pool-3-thread-1] jvm - collector name {:name=>"ParNew"}
[DEBUG] 2019-05-14 18:09:20.600 [pool-3-thread-1] jvm - collector name {:name=>"ConcurrentMarkSweep"}

[DEBUG] 2019-05-14 18:09:20.828 [logstash-pipeline-flush] PeriodicFlush - Pushing flush onto pipeline.
[DEBUG] 2019-05-14 18:09:20.828 [[main]>worker2] grok - Running grok filter {:event=>#<LogStash::Event:0x4951e5bb>}
[DEBUG] 2019-05-14 18:09:20.852 [[main]>worker2] grok - Event now:  {:event=>#<LogStash::Event:0x4951e5bb>}
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
{
      "@timestamp" => 2019-05-14T16:09:20.711Z,
    "memcache_key" => "c1bbd73460750d57574bf1e274462ede",
        "@version" => "1",
            "host" => "logstash",
        "uri_fqdn" => "www.google.pl",
         "message" => "www.google.pl"
}
[DEBUG] 2019-05-14 18:09:25.618 [pool-3-thread-3] jvm - collector name {:name=>"ParNew"}
[DEBUG] 2019-05-14 18:09:25.619 [pool-3-thread-3] jvm - collector name {:name=>"ConcurrentMarkSweep"}
[DEBUG] 2019-05-14 18:09:25.828 [logstash-pipeline-flush] PeriodicFlush - Pushing flush onto pipeline.

Having the key as a sprintf reference is fine. The value should not be.

set => { "[uri_fqdn]" => "%{memcache_key}" }

That does the job done. The memcached I am running was VERSION 1.4.33 on 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux

Thanks for the assist!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.