# Vega-Lite in Kibana visualization problem

**URL:** <https://discuss.elastic.co/t/vega-lite-in-kibana-visualization-problem/330711>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [April 25, 2023, 8:40am UTC](https://discuss.elastic.co/t/vega-lite-in-kibana-visualization-problem/330711 "2023-04-25T08:40:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinez06](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@martinez06](https://discuss.elastic.co/u/martinez06)\
**Post date:** [April 25, 2023, 8:40am UTC](https://discuss.elastic.co/t/vega-lite-in-kibana-visualization-problem/330711/1 "2023-04-25T08:40:54Z")

</div>

Hi,  
Im trying to create a custom vizualization using Vega-Lite in Kibana. I have the source data:  
syslog\_ip\_address, syslog\_url,syslog\_status. For each ip address i check status of three url and i want to visualise it in dashboard. I created the below code but i cant aggregate it how i want.  
Now when one of the pages stop responding i dont see which site and from wchich ip address

![image](https://us1.discourse-cdn.com/elastic/original/3X/f/d/fd64acb6ea1566165bda223aa44654bb65d0b9ca.png)

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "data": {
    "name": "check_data",
    "url": {
      "index": "logs-filebeat.d365*",
      "body": {
        "_source": ["@timestamp", "syslog_ip_address", "syslog_url", "syslog_status"],
        "size": 200
      }
    },
    "format": {"property": "hits.hits"}
  },

   "facet": {
    "field": "_source.syslog_ip_address",
    "columns": 4,
    "title": "IP Addresses"
  },
    
  
  "spec": {
    "layer": [
      {
        "mark": {"type": "text"},
        "encoding": {
          "text": {"field": "_source.syslog_status"},
          "color": {"value": "white"}
        }
      },
      {
        "mark": {"type": "rect"},
        "width": 60,
        "height": 40,
        "encoding": {
          "href": {"field": "_source.syslog_url"},
          "color": {
            "condition": {
              "test": "datum._source.syslog_status == '200'",
              "value": "green"
            },
            "condition": {
              "test": "datum._source.syslog_status != '200' ",
              "value": "red"
            },
            "value": "green"
          }
        }
      },
      {
        "mark": {"type": "text"},
        "encoding": {
          "text": {
            "condition": {
              "test": "datum._source.syslog_status == '200'",
              "field": "_source.syslog_status"
            },
            "condition": {
              "test": "datum._source.syslog_status != '200'",
              "value": "PROBLEM"
            },
            "value": "OK"
          },
          "color": {"value": "white"}
        }
      }
    ],
  }
}

```

I woudl be greatfull for help

---

<div class="post-metadata">

**Author:** ![nickpeihl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nickpeihl/32/112622_2.png) [@nickpeihl](https://discuss.elastic.co/u/nickpeihl)\
**Post date:** [April 26, 2023, 6:12pm UTC](https://discuss.elastic.co/t/vega-lite-in-kibana-visualization-problem/330711/2 "2023-04-26T18:12:29Z")

</div>

I would start by confirming that your `data.url.body` query is returning the data you want. It looks like it will return up to 200 logs. You can check the query results in your Kibana Dev Console.

```auto
POST logs-filebeat.d365*/_search
{
  "_source": ["@timestamp", "syslog_ip_address", "syslog_url", "syslog_status"],
  "size": 200
}

```

But these logs might return multiple results for the same IP address. Maybe you want to only get the `syslog_status` for the latest status for each IP address? In that case, I would suggest using a top hits aggregation like [this example](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html#_example_6).

---

<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:** [May 24, 2023, 6:12pm UTC](https://discuss.elastic.co/t/vega-lite-in-kibana-visualization-problem/330711/3 "2023-05-24T18:12:55Z")

</div>

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