Need help to create logstash json.conf file

i have jenkins job that outputs a json file.
i want to know how can i build the logstash conf file in order to export it to Elasticsearch
i have tried different configs but always failing on parsing errors.
json file looks like this

{

    "_class": "org.jenkinsci.plugins.workflow.job.WorkflowRun",

    "actions": [{},

        {

            "_class": "hudson.model.CauseAction",

            "causes": [{

                    "_class": "hudson.model.Cause$UserIdCause",

                    "shortDescription": "Started by user koko melon",

                    "userId": "koko-melon",

                    "userName": "koko melon"

                },

                {

                    "_class": "org.jenkinsci.plugins.workflow.cps.replay.ReplayCause",

                    "shortDescription": "Replayed #221"

                }

            ]

        },

        {

            "_class": "jenkins.metrics.impl.TimeInQueueAction",

            "blockedDurationMillis": 0,

            "blockedTimeMillis": 0,

            "buildableDurationMillis": 0,

            "buildableTimeMillis": 0,

            "buildingDurationMillis": 0,

            "executingTimeMillis": 0,

            "executorUtilization": 1,

            "subTaskCount": 0,

            "waitingDurationMillis": 7,

            "waitingTimeMillis": 7

        },

        {},

        {},

        {},

        {

            "_class": "org.jenkinsci.plugins.workflow.cps.EnvActionImpl"

        },

        {},

        {},

        {},

        {},

        {},

        {},

        {},

        {

            "_class": "org.jenkinsci.plugins.displayurlapi.actions.RunDisplayAction"

        },

        {

            "_class": "org.jenkinsci.plugins.pipeline.modeldefinition.actions.RestartDeclarativePipelineAction"

        },

        {},

        {},

        {

            "_class": "org.jenkinsci.plugins.workflow.job.views.FlowGraphAction"

        },

        {},

        {},

        {},

        {}

    ],

    "artifacts": [],

    "building": true,

    "description": null,

    "displayName": "#223",

    "duration": 0,

    "estimatedDuration": 5785,

    "executor": {

        "_class": "hudson.model.OneOffExecutor"

    },

    "fullDisplayName": "Test Jobs �� test-koko melon #223",

    "id": "223",

    "keepLog": false,

    "number": 223,

    "queueId": 23919772,

    "result": "SUCCESS",

    "timestamp": 1637890617063,

    "url": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/223/",

    "changeSets": [],

    "culprits": [],

    "nextBuild": null,

    "previousBuild": {

        "number": 222,

        "url": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/222/"

    },

    "MANPATH": "/opt/quest/man:",

    "JENKINS_NODE_COOKIE": "afe6b7c4-6fa6-494d-96b0-1bc8a156f19c",

    "XDG_SESSION_ID": "1",

    "BUILD_URL": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/223/",

    "COMMIT_BACKUP_DIR": "/auto/server-jenkins/per-commit-backup",

    "SHELL": "/bin/bash",

    "HUDSON_SERVER_COOKIE": "4c35f5ec9bfbda2b",

    "server_JENKINS_ROOT": "/auto/server-jenkins",

    "STAGE_NAME": "Declarative: Post Actions",

    "SSH_CLIENT": "8.8.8.8",

    "BUILD_TAG": "jenkins-test-koko-melon-delete-223",

    "LEABA_JENKINS_ROOT": "/local/jenkins",

    "LSF_8C": "\"/auto/edatools/bin/bsub -Is -P server-sw.p -q build -R \"rusage[cores=8]\"\"",

    "JOB_URL": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/",

    "LC_ALL": "en_US",

    "WORKSPACE": "/auto/server-jenkins/workspace/test/koko-melon-delete",

    "RUN_CHANGES_DISPLAY_URL": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/223/display/redirect?page=changes",

    "USER": "koko-melon",

    "SUDO_PROMPT": "Enter RADIUS password (http://otp for help):",

    "RUN_ARTIFACTS_DISPLAY_URL": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/223/display/redirect?page=artifacts",

    "JENKINS_HOME": "/var/jenkins_home",

    "PATH": "/auto/edatools/bin:/auto/asic-tools/sw/openjdk/1.8.0/bin:/auto/asic-tools/sw/git/2.17.1/bin:/usr/local/bin:/usr/bin",

    "MAIL": "/var/mail/koko-melon",

    "RUN_DISPLAY_URL": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/223/display/redirect",

    "_": "/usr/bin/jq",

    "PWD": "/auto/server-jenkins/workspace/test/koko-melon-delete",

    "HUDSON_URL": "https://server.com/jenkins/server-sw-jenkins/",

    "LANG": "en_US",

    "JOB_NAME": "test/koko-melon-delete",

    "BUILD_DISPLAY_NAME": "#223",

    "JENKINS_URL": "https://server.com/jenkins/server-sw-jenkins/",

    "BUILD_ID": "223",

    "JOB_BASE_NAME": "koko-melon-delete",

    "RUN_TESTS_DISPLAY_URL": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/223/display/redirect?page=tests",

    "SHLVL": "3",

    "HOME": "/users/koko-melon",

    "WORKSPACE_TMP": "/auto/server-jenkins/workspace/test/koko-melon-delete@tmp",

    "EXECUTOR_NUMBER": "10",

    "JENKINS_SERVER_COOKIE": "durable-3733a4ae1f6b5425dc12bb34f5918351",

    "LSF_FARM": "sjc",

    "LOGNAME": "koko-melon",

    "HUDSON_HOME": "/var/jenkins_home",

    "SSH_CONNECTION": "8.8.8.8",

    "NODE_NAME": "server-agent-8",

    "JOB_DISPLAY_URL": "https://server.com/jenkins/server-sw-jenkins/job/test/job/koko-melon-delete/display/redirect",

    "BUILD_NUMBER": "223",

    "HUDSON_COOKIE": "6d8ec214-c0fa-493e-a729-40538432ed4c",

    "XDG_RUNTIME_DIR": "/run/user/50009752"

}

Are you using a file input? Are you using a multiline codec to combine the lines into a single event?

i found out what was my problem.
logstash doesn't like pretty json format.
when i transferred it to 1 liner it all magically started to work :slight_smile:

Right, that's what you would use a multiline codec for if you cannot fix the source file.

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