Urlparam in pdf generate POST url not working

Hi,

I have tried to add urlparam in generate PDF POST url, but it doesn't work. It works fine without urlparam.

I added the urlparam to the POST url manually:

https://xxxxx.ca-central-1.aws.elastic-cloud.com:9243/api/reporting/generate/printablePdf?jobParams=(browserTimezone:America%2FPhoenix,layout:(dimensions:(height:792,width:612),id:preserve_layout),objectType:'canvas%20workpad',relativeUrls:!(%2Fapp%2Fcanvas%3FmyVar%3D1w%23%2Fexport%2Fworkpad%2Fpdf%2Fworkpad-6af74cef-477e-4191-a579-d5d0f87decbf%2Fpage%2F1),title:'Hokaho%20Report')

The return json looks good, the param is in the relativeUrl:

{
    "path": "/api/reporting/jobs/download/kgbqyyge000q334cc0f5xo31",
    "job": {
        "id": "kgbqyyge000q334cc0f5xo31",
        "index": ".reporting-2020-10-11",
        "_seq_no": 78,
        "_primary_term": 3,
        "jobtype": "printable_pdf",
        "created_by": "elastic",
        "payload": {
            "basePath": "",
            "browserTimezone": "America/Phoenix",
            "forceNow": "2020-10-16T04:23:48.204Z",
            "headers": "<a very long string>",
            "layout": {
                "dimensions": {
                    "height": 792,
                    "width": 612
                },
                "id": "preserve_layout"
            },
            "objects": [
                {
                    "relativeUrl": "/app/canvas?myVar=1w#/export/workpad/pdf/workpad-6af74cef-477e-4191-a579-d5d0f87decbf/page/1"
                }
            ],
            "title": "Hokaho Report",
            "type": "canvas workpad"
        },
        "timeout": 120000,
        "max_attempts": 3,
        "priority": 10,
        "browser_type": "chromium"
    }
}

Then use the path to get the pdf, it returns 500 even I increased the timeout:

{
    "statusCode": 500,
    "error": "Internal Server Error",
    "message": "Reporting generation failed: Max attempts reached (3)"
}
xpack.reporting.queue.timeout: 120000

I coped the relativeUrl in browser it works fine.

I'm not sure if that's the correct way to add urlparam in the POST url. If not, how can I pass url param in the POST url?

Thanks,
Frank

Hey there Frank,

What Kibana/ES version are you currently running? Do you get any errors in your Kibana log from your reporting plugin?

Additionally, if you manually navigate to the relative URL in the JSON response, does that throw a 500? (You should have the canvas workpad page load up)

I was running kibana/ES locally on my machine and was able to follow your steps and had a PDF generated without issue. I'm using the main branch in Kibana, however, so I suspect we're using different versions.

Hi,

Thanks for reply. I'm running version 7.9.0. Sorry I'm new to ES not sure where to check the reporting plugin. But the Kibana crashed after I request 2-3 times with params in URL and automatically restarted. Also my shards count increased from 64 to 100, looks like Kibana created a few indexes. If I manually navigate to the relative URL it works fine. It generated the poster with the params in URL. Only using the POST URL doesn't work and crashed.

Here are the last two documents in the reporting index:

      {
        "_index" : ".reporting-2020-10-11",
        "_type" : "_doc",
        "_id" : "kgbnx1tg000q11971d9xdkrk",
        "_score" : 1.0,
        "_source" : {
          "jobtype" : "printable_pdf",
          "meta" : {
            "objectType" : "canvas workpad",
            "layout" : "preserve_layout"
          },
          "payload" : {
            "basePath" : "",
            "browserTimezone" : "America/Phoenix",
            "forceNow" : "2020-10-16T02:58:20.344Z",
            "headers" : "a very long string",
            "layout" : {
              "dimensions" : {
                "height" : 792,
                "width" : 612
              },
              "id" : "preserve_layout"
            },
            "objects" : [
              {
                "relativeUrl" : "/app/canvas?myVar=1w#/export/workpad/pdf/workpad-6af74cef-477e-4191-a579-d5d0f87decbf/page/1"
              }
            ],
            "title" : "Hokaho Report",
            "type" : "canvas workpad"
          },
          "created_by" : "elastic",
          "timeout" : 120000,
          "process_expiration" : "2020-10-16T03:04:27.244Z",
          "created_at" : "2020-10-16T02:58:20.404Z",
          "attempts" : 3,
          "max_attempts" : 3,
          "status" : "failed",
          "browser_type" : "chromium",
          "kibana_id" : "812f46e4-d62e-4d59-a317-9b76a1469192",
          "kibana_name" : "4555e844d3aa",
          "started_at" : "2020-10-16T03:02:27.244Z",
          "output" : {
            "content_type" : false,
            "content" : "Max attempts reached (3)"
          },
          "completed_at" : "2020-10-16T03:04:30.269Z"
        }
      },
      {
        "_index" : ".reporting-2020-10-11",
        "_type" : "_doc",
        "_id" : "kgbnccr8000z11971d0048kh",
        "_score" : 1.0,
        "_source" : {
          "jobtype" : "printable_pdf",
          "meta" : {
            "objectType" : "canvas workpad",
            "layout" : "preserve_layout"
          },
          "payload" : {
            "basePath" : "",
            "browserTimezone" : "America/Phoenix",
            "forceNow" : "2020-10-16T02:42:14.722Z",
            "headers" : "<a very long string>",
            "layout" : {
              "dimensions" : {
                "height" : 792,
                "width" : 612
              },
              "id" : "preserve_layout"
            },
            "objects" : [
              {
                "relativeUrl" : "/app/canvas?myVal=1w#/export/workpad/pdf/workpad-6af74cef-477e-4191-a579-d5d0f87decbf/page/1"
              }
            ],
            "title" : "Hokaho Report",
            "type" : "canvas workpad"
          },
          "created_by" : "elastic",
          "timeout" : 120000,
          "process_expiration" : "2020-10-16T02:51:07.715Z",
          "created_at" : "2020-10-16T02:42:14.804Z",
          "attempts" : 2,
          "max_attempts" : 3,
          "status" : "failed",
          "browser_type" : "chromium",
          "kibana_id" : "812f46e4-d62e-4d59-a317-9b76a1469192",
          "kibana_name" : "4555e844d3aa",
          "started_at" : "2020-10-16T02:49:07.715Z",
          "output" : {
            "content_type" : false,
            "content" : "Error: Protocol error (Page.captureScreenshot): Internal error"
          },
          "completed_at" : "2020-10-16T02:50:08.624Z"
        }
      }

Here are the indexes Kibana generated:

green open .apm-agent-configuration                 2WkTMKzvSq-IqIFyo0cPMQ 1 1      0      0    522b    261b
green open .apm-custom-link                         VtenBNxBQKSMqTOQb7cfVA 1 1      0      0    522b    261b
green open .async-search                            flwXGLYyQMikPSl7qrGTeQ 1 1      0      0    530b    265b
green open .kibana-event-log-7.9.0-000001           zFneWq91QOmvLD7Tt9IqaQ 1 1      2      0  21.9kb  10.9kb
green open .kibana-event-log-7.9.0-000002           olEEb_zURvSxCIJFaxbLoA 1 1      4      0  32.7kb  16.3kb
green open .kibana-event-log-7.9.0-000003           d_8wlqAeSBS1s0pMbWmJ_g 1 1      0      0    416b    208b
green open .kibana_1                                TpXzEBbMQ_SyXo8clSIKBQ 1 1   1729    270 172.3mb    85mb
green open .kibana_task_manager_1                   MZES2753Rc2I9i4eYCn9yQ 1 1      6     26   2.5mb 163.4kb
green open .reporting-2020-10-11                    9zsRdq-7T4SGSwWenAR4jA 1 1     21      5   4.8mb   2.4mb
green open .security-7                              kCqb_qlaT62zpFqCP5kW-g 1 1     52      0 258.4kb 128.8kb
green open .security-tokens-7                       JVqeDoPNTsmXs-9E5XgW1Q 1 1     52      1 205.2kb 102.6kb
green open apm-7.9.0-error-000001                   t-yFzR1ASxupwSMsUmw99Q 1 1      0      0    522b    261b
green open apm-7.9.0-error-000002                   XBJy_W-pRHSH69wQJgHzgA 1 1      0      0    522b    261b
green open apm-7.9.0-error-000003                   AfYv54sWQEqAJDr8hIl29w 1 1      0      0    416b    208b
green open apm-7.9.0-metric-000001                  6rYY0T5SS-SmjintljugFQ 1 1      0      0    522b    261b
green open apm-7.9.0-metric-000002                  8nXymsOoSPOCSRjvrmQzag 1 1      0      0    522b    261b
green open apm-7.9.0-metric-000003                  lkaAkY1kTCG6KUBk1K5Jlw 1 1      0      0    416b    208b
green open apm-7.9.0-onboarding-2020.08.21          VOgXBotySXiNrBECb8ycXw 1 1      1      0  14.7kb   7.3kb
green open apm-7.9.0-profile-000001                 P_qT63M0TM6k33tx2YPpjQ 1 1      0      0    522b    261b
green open apm-7.9.0-profile-000002                 ml8WHLtQSr-7GA84h_kZ9A 1 1      0      0    522b    261b
green open apm-7.9.0-profile-000003                 NzZe9bUWR1qKPbWNO0fvyA 1 1      0      0    416b    208b
green open apm-7.9.0-span-000001                    pZY-3Q2XR4aIj5mjq1HIAQ 1 1      0      0    522b    261b
green open apm-7.9.0-span-000002                    G41j3iZqT3qjWMMtpMpLpg 1 1      0      0    522b    261b
green open apm-7.9.0-span-000003                    ckl0TBg5RYSOtbtFezx2hw 1 1      0      0    416b    208b
green open apm-7.9.0-transaction-000001             ZYDvnfsLTj6CkS9i1sNseQ 1 1      0      0    522b    261b
green open apm-7.9.0-transaction-000002             GIU8mHu4SOmKifTOHNTgcw 1 1      0      0    522b    261b
green open apm-7.9.0-transaction-000003             V-gYxh1STGSb2ecLd6bVOA 1 1      0      0    416b    208b

Sorry I don't know how to print out my configuration so just took a screenshot:

es-settings-1

Thanks,

Frank

I just tried again, it looks like the report can't take urlparam input in POST URL. I tried keep the params in URL but remove the code {urlparam "myVar"}, it works fine with the POST URL. But once I use {urlparam "myVar"} then it doesn't work with the POST URL, but works by navigate the relative URL. Maybe the POST URL filtered url parameters when generating poster? Here is my query:

filters
| timelion
  query=".es(q='Sp_dol:>0 AND Municipality.keyword:Toronto',index=rets_*_*d*property,timefield=Cd,metric=avg:Sp_dol)" interval={urlparam "myVar"}
| tail 2
| math "first(@timestamp)"
| formatdate "MM/DD/YYYY"
| markdown {context}
| render

Thanks,

Frank

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