# Memcached not working

**URL:** <https://discuss.elastic.co/t/memcached-not-working/307822>\
**Category:** Logstash\
**Created:** [June 22, 2022, 3:57am UTC](https://discuss.elastic.co/t/memcached-not-working/307822 "2022-06-22T03:57:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulohperes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paulohperes/32/107556_2.png) [@paulohperes](https://discuss.elastic.co/u/paulohperes)\
**Post date:** [June 22, 2022, 3:57am UTC](https://discuss.elastic.co/t/memcached-not-working/307822/1 "2022-06-22T03:57:26Z")

</div>

I am trying to create a pipeline using the memcached plugin, however it is not working when I create a key in the cache in dictionary format.

Here's my pipeline:

```auto
input {
    udp {
        port => 514
        type => syslog
    }
}

filter {

    syslog_pri {}

    mutate {
        copy => {
            "[host][ip]" => "ip"
        }
    }

    memcached {
        hosts => ["localhost"]
        get => {
            "%{ip}" => "[host_detail]"
        }
    }

    ### Drop messages
    if "ksyncd_ksync_handle_asyncmsg" in [message] {drop {}}
    if "if_process_obj_index: Zero length TLV!" in [message] {drop {}}
    if "get tlv ppfeid" in [message] {drop {}}
    if "hw.chassis.startup_time update to" in [message] {drop {}}
    if "UI_LOGOUT_EVENT: User" in [message] {drop {}}
    if "UI_LOGIN_EVENT: User" in [message] {drop {}}
    if "UI_AUTH_EVENT: Authenticated user" in [message] {drop {}}
    if "UI_CHILD_EXITED: Child exited:" in [message] {drop {}}
    if "UI_CHILD_START: Starting child" in [message] {drop {}}
    if "UI_CHILD_STATUS: Cleanup child" in [message] {drop {}}
    if "Accepted password for" in [message] {drop {}}
    if "Accepted keyboard-interactive/pam" in [message] {drop {}}
    if "tac_send_authen: unexpected EOF from server" in [message] {drop {}}
    if "SSHD_LOGIN_FAILED: Login failed for user" in [message] {drop {}}
    if "error: PAM: authentication error for" in [message] {drop {}}
    if "Failed password for" in [message] {drop {}}
    if "Connection closed by" in [message] {drop {}}
    if "error: PAM: authentication information is unavailable for" in [message] {drop {}}
    if "exited, status 255" in [message] {drop {}}
    if "(root) CMD" in [message] {drop {}}
    if "bln3_script" in [message] {drop {}}
    if "backaggr" in [message] {drop {}}
    if "rpc command" in [message] {drop {}}
    if "hw.chassis.startup_time update to" in [message] {drop {}}
    if "SSHD_LOGIN_FAILED: Login failed for user" in [message] {drop {}}
    
}

output {
    stdout {
        codec => rubydebug        
    }
}

```

I'm loading the entries in the cache via a python script that reads a json file, I'm printing it right after the insertion and it's ok.

```auto
import json
from pprint import pprint
from typing import List
from pydantic import BaseModel
from pymemcache import Client, serde

class Host(BaseModel):
    ip: str
    hostname: str
    type: str
    vendor: str
    model: str

if __name__ == " __main__":

    with open("hosts.json") as hosts_file:
        data = json.load(hosts_file)
        
        hosts: List[Host] = []

        for i in data["hosts"]:
            hosts.append(Host(ip=i["ip"], hostname=i["hostname"], type=i["type"], vendor=i["vendor"], model=i["model"]))

        memcached: Client = Client("localhost", serde=serde.pickle_serde)
        memcached.flush_all()
        
        for host in hosts:
            memcached.set(host.ip, {"hostname": host.hostname, "type": host.type, "vendor": host.vendor, "model": host.model})

        for host in hosts:            
            print(memcached.get(host.ip))

```

Output pyhton file:

```auto
10.221.64.251
{'hostname': 'test1', 'type': 'router', 'vendor': 'Huawei', 'model': 'NE40X8'}
10.185.96.7
{'hostname': 'test2', 'type': 'router', 'vendor': 'Juniper', 'model': 'MX960'}
10.113.150.4
{'hostname': 'test3', 'type': 'router, 'vendor': 'Nokia', 'model': 'SR7750'}

```

My question is: does memcached plugin support dictionaries?

---

<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:** [July 20, 2022, 3:58am UTC](https://discuss.elastic.co/t/memcached-not-working/307822/2 "2022-07-20T03:58:25Z")

</div>

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