# \[SOLVED\] Logstash memcached does not work as expected

**URL:** <https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029>\
**Category:** Logstash\
**Created:** [May 14, 2019, 3:36pm UTC](https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029 "2019-05-14T15:36:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [May 14, 2019, 3:36pm UTC](https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029/1 "2019-05-14T15:36:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 14, 2019, 3:46pm UTC](https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029/2 "2019-05-14T15:46:21Z")

</div>

If you run with log.level trace do you see a TRACE [message](https://github.com/logstash-plugins/logstash-filter-memcached/blob/4bf423027335b5521b09005404e2614b0cf800fc/lib/logstash/filters/memcached.rb#L136) as it sets each item?

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [May 14, 2019, 3:52pm UTC](https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029/3 "2019-05-14T15:52:16Z")

</div>

# 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.

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [May 14, 2019, 4:06pm UTC](https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029/4 "2019-05-14T16:06:27Z")

</div>

**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.

````

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 14, 2019, 4:41pm UTC](https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029/5 "2019-05-14T16:41:39Z")

</div>

> [@pastechecker](#):
>
> set =\> {  
> "%{uri\_fqdn}" =\> "%{memcache\_key}"  
> }

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

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

```

---

<div class="post-metadata">

**Author:** ![pastechecker](https://avatars.discourse-cdn.com/v4/letter/p/0ea827/32.png) [@pastechecker](https://discuss.elastic.co/u/pastechecker)\
**Post date:** [May 15, 2019, 10:06am UTC](https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029/6 "2019-05-15T10:06:09Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 12, 2019, 10:16am UTC](https://discuss.elastic.co/t/solved-logstash-memcached-does-not-work-as-expected/181029/7 "2019-06-12T10:16:58Z")

</div>

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