Ad Widget

Collapse

Prototype Item is not working but manual Item with same Parameters is

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • marcohald
    Junior Member
    • Apr 2024
    • 3

    #1

    Prototype Item is not working but manual Item with same Parameters is

    I try to get the modified timestamp of the Files via a Discovery Rule that depends on filesystem listing.
    the manual created item is working without an issue, but the prototype item is only created and no data could be get for it.
    I have no Idea why it is working when manually created, but not as item prototype
    Code:
    [{"basename":"columnstore","pathname":"/srv/mysqldumps/nightly/columnstore","dirname":"/srv/mysqldumps/nightly","type":"dir","user":"mysql","group":"adm","permissions":"2775","uid":111,"gid":4,"size":4096,"time":{"access":"2024-04-19T12:11:42+0200","modify":"2024-04-19T12:11:42+0200","change":"2024-04-19T12:40:09+0200"},"timestamp":{"access":1713521502,"modify":1713521502,"change":1713523209}},{"basename":"zabbix.sql.gz","pathname":"/srv/mysqldumps/nightly/zabbix.sql.gz","dirname":"/srv/mysqldumps/nightly","type":"file","user":"root","group":"adm","permissions":"0660","uid":0,"gid":4,"size":3564615,"time":{"access":"2024-04-19T12:44:03+0200","modify":"2024-04-19T12:44:05+0200","change":"2024-04-19T12:44:05+0200"},"timestamp":{"access":1713523443,"modify":1713523445,"change":1713523445}}]
    Error:

    Code:
    Preprocessing failed for: [{"basename":"columnstore","pathname":"/srv/mysqldumps/nightly/columnstore","dirname":"/srv/mysql...
    1. Failed: cannot extract value from json by path "$..[?(@.basename == "{#STATUSFILE}")].timestamp.modify": no data matches the specified path
    ​


    ​​Click image for larger version

Name:	image.png
Views:	327
Size:	42.0 KB
ID:	482738
    Click image for larger version

Name:	image.png
Views:	154
Size:	25.8 KB
ID:	482739
    This is my template:
    Code:
    {
        "zabbix_export": {
            "version": "6.4",
            "template_groups": [
                {
                    "uuid": "748ad4d098d447d492bb935c907f652f",
                    "name": "Templates/Databases"
                }
            ],
            "templates": [
                {
                    "uuid": "5a04d103d92f431a8ed37f122f02aac1",
                    "template": "filewatcher-test",
                    "name": "filewatcher-test",
                    "groups": [
                        {
                            "name": "Templates/Databases"
                        }
                    ],
                    "items": [
                        {
                            "uuid": "8e7558bda9604e46849d8ae459d3ae9d",
                            "name": "manual zabbix.sql.gz",
                            "type": "DEPENDENT",
                            "key": "a.test.1",
                            "delay": "0",
                            "preprocessing": [
                                {
                                    "type": "JSONPATH",
                                    "parameters": [
                                        "$..[?(@.basename == \"zabbix.sql.gz\")].timestamp.modify"
                                    ]
                                },
                                {
                                    "type": "LTRIM",
                                    "parameters": [
                                        "["
                                    ]
                                },
                                {
                                    "type": "RTRIM",
                                    "parameters": [
                                        "]"
                                    ]
                                }
                            ],
                            "master_item": {
                                "key": "vfs.dir.get[/srv/mysqldumps/nightly/]"
                            },
                            "tags": [
                                {
                                    "tag": "Application",
                                    "value": "Test-MySQL"
                                }
                            ]
                        },
                        {
                            "uuid": "2ce61f7133c5404e9c6f8e450fdfa75d",
                            "name": "Filesystem list /srv/mysqldumps/nightly/",
                            "key": "vfs.dir.get[/srv/mysqldumps/nightly/]",
                            "history": "7d",
                            "trends": "0",
                            "value_type": "TEXT",
                            "tags": [
                                {
                                    "tag": "Application",
                                    "value": "Test-MySQL"
                                }
                            ]
                        }
                    ],
                    "discovery_rules": [
                        {
                            "uuid": "04ee44644853462c916231f0238762c3",
                            "name": "Automatic discovery test",
                            "type": "DEPENDENT",
                            "key": "discovery.files.srv.mysqldumps.nightly",
                            "delay": "0",
                            "item_prototypes": [
                                {
                                    "uuid": "beea433e672b40c1ba68c447c4510be6",
                                    "name": "automatic {#BASENAME}",
                                    "type": "DEPENDENT",
                                    "key": "statusfile.modified.timestamp[{#BASENAME}]",
                                    "delay": "0",
                                    "trends": "0",
                                    "value_type": "TEXT",
                                    "preprocessing": [
                                        {
                                            "type": "JSONPATH",
                                            "parameters": [
                                                "$..[?(@.basename == \"{#STATUSFILE}\")].timestamp.modify"
                                            ]
                                        },
                                        {
                                            "type": "LTRIM",
                                            "parameters": [
                                                "["
                                            ]
                                        },
                                        {
                                            "type": "RTRIM",
                                            "parameters": [
                                                "]"
                                            ]
                                        }
                                    ],
                                    "master_item": {
                                        "key": "vfs.dir.get[/srv/mysqldumps/nightly/]"
                                    },
                                    "tags": [
                                        {
                                            "tag": "Application",
                                            "value": "Test-MySQL"
                                        }
                                    ]
                                }
                            ],
                            "master_item": {
                                "key": "vfs.dir.get[/srv/mysqldumps/nightly/]"
                            },
                            "lld_macro_paths": [
                                {
                                    "lld_macro": "{#BASENAME}",
                                    "path": "$.basename"
                                },
                                {
                                    "lld_macro": "{#MODIFY}",
                                    "path": "$.timestamp.modify"
                                },
                                {
                                    "lld_macro": "{#SIZE}",
                                    "path": "$.size"
                                }
                            ],
                            "preprocessing": [
                                {
                                    "type": "DISCARD_UNCHANGED_HEARTBEAT",
                                    "parameters": [
                                        "1d"
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    }​

  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4806

    #2
    {#STATUSFILE} .. it has no value.. Shouldn't there be {#BASENAME} instead? jsonpath is evil..

    Comment

    Working...