Canvas markdown is not showing data

Hi

In canvas markdown. I am using elastic sql to pull data from metric beat and sorting it to latest document as I wanted to see the latest result of the jenkins job.
SELECT http.json_test.building,http.json_test.url,http.json_test.result FROM "metricbeat-*" ORDER BY "@timestamp" DESC LIMIT 1

This is the correct result.

Now I want to show only "http.json_test.url" value on markdown. when I used this code in markdown content I can see the column names as expected.

        {{#each columns}}
        {{name}}
        {{/each}}

image

But when I change the code to below I get a blank results. Please guide me how I can achieve this.

 {{#each rows}}
 {{http.json_test.url}} 
 {{/each}}

image

Hi @syedsfayaz,

Since your column name contains ., try putting it in single quotes, or escaped double quotes:

 {{#each rows}}
 {{\"http.json_test.url\"}} 
 {{/each}}

Alternatively if you are using SQL, you could rename it there:

SELECT http.json_test.building, http.json_test.url as url, http.json_test.result FROM "metricbeat-*" ORDER BY "@timestamp" DESC LIMIT 1

And then in the markdown:

 {{#each rows}}
 {{url}} 
 {{/each}}
1 Like

@lukeelmers Thank you for your reply. Single quotes or backslash did not work but adding an alias names worked .

  1. Can I use the same settings in visual builder markdown. Will this work?
  2. Since I am having result column(Success/failed) . I want to change the color for markdown to "Red " when it is failed and green when successful . Any idea how I can achieve it.
  1. Can I use the same settings in visual builder markdown. Will this work?

Yes, visual builder supports handlebar templates in markdown, however, it does not use the same querying infrastructure that Canvas uses (so you won't be able to use the same Canvas expression with SQL to get your data).

If you are able to get the results you are looking for by configuring visual builder, then it should be possible to access the values from within the markdown. The data is just structured a bit differently.

  1. Since I am having result column(Success/failed) . I want to change the color for markdown to "Red " when it is failed and green when successful . Any idea how I can achieve it.

I don't think this exactly helps in your situation, but generally you can do this by editing the expression directly and using the if statement inside of the font argument:

markdown font={font color={if {getCell column="http.json_test.result" row=0 | eq "success"} then=green else=red}} "hello"

However, I don't think you can specify multiple color values within a single markdown element -- so if you were wanting to color each item in your list differently, I don't think that will work here.

In my example above I am using getCell to pull from row 0 of the http.json_test.result column -- so as you can see, you're limited on setting a single color.

@lukeelmers I want to change the color of entire markdown widget, So I can show it as a status indicator. It will look like this.
image

One more last question. Is it possible to change the shape of markdown widget. In which case I can create multiple markdowns and added them side by side to show a pipeline.

You can't change the shape of the markdown widget, but you could use a separate shape element and conditionally color it. The implementation of this would involve a similar technique to what I described above, only applied to the shape function instead.

This thread may be of interest, as it is solving a very similar problem: Can't get shape to render with correct color

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