# Displaying Images from Python scripts

**URL:** <https://community.grafana.com/t/displaying-images-from-python-scripts/65767>\
**Category:** Developers & API\
**Tags:** datasource, api\
**Created:** [May 16, 2022, 1:46pm UTC](https://community.grafana.com/t/displaying-images-from-python-scripts/65767 "2022-05-16T13:46:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kinorii](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/kinorii/32/23259_2.png) [@Kinorii](https://community.grafana.com/u/Kinorii)\
**Post date:** [May 16, 2022, 1:46pm UTC](https://community.grafana.com/t/displaying-images-from-python-scripts/65767/1 "2022-05-16T13:46:23Z")

</div>

Hi there, I’m looking for some help to achieve a project. I hope my issue will be easy enough to understand and please forgive my english issues.

- What Grafana version and what operating system are you using?

- **What** are you trying to achieve?

I’m working on a project and I just want to be able to display images coming from a Python script.  
Currently my Python script is starting a camera and fetching some frames from it.  
Then i’m encoding these frames into Base64 and trying to send them to the Grafana Live measurement ( /api/push/live/custom\_stream\_id with Telegraf )  
I succeed in sending values like maths functions, but I couldnt send any strings with this method.  
My idea was trying to make a dashboard with images displaying like Ed Welch did in his Nissan Leaf work : [Nissan Leaf -\> Cloud all the things - GrafanaCONline | Grafana Labs](https://grafana.com/go/grafanaconline/2020/nissan-leaf-cloud-all-the-things/)

In this work he talked about Grafana LOKI to store Base64 images, but i didnt find any documentation about that ( probably because i’m very new in this ).

- **How** are you trying to achieve it?

I tried with this piece of code:

 ![test](https://us1.discourse-cdn.com/grafana/original/3X/5/3/5310d471b6ea2a30c8a738bb4ef76bdd41697f9b.png)

Please note that i tried with this code ( maths one ) as well and it worked very fine :

 ![test2](https://us1.discourse-cdn.com/grafana/original/3X/9/b/9b9cbc4d523bcbd03fbf820b85f37155824935db.png)

With this one, I was able to create a live dashboard as it is mentionned in Grafana Stream Metrics documentation. ( Without websockets )

- What happened?

With the First piece of code i’m getting an Internal Server Error ( 500 ) and Logs from grafana said : Error parsing metrics.  
I’m sure that it come from the “metrics format” but didnt manage to find how to solve it.

- What did you **expect** to happen?

I wanted to have the base64 encoded images in a Grafana table to display it.

- Did you receive any errors in the Grafana UI or in related logs? If so, please tell us **exactly** what they were.

Error Parsing metrics in Systemctl status grafana-server

- Did you follow any online instructions? If so, what is the URL?

I took some ideas from this topic : [https://community.grafana.com/t/how-to-connect-streaming-data-source-to-websocket/54927](https://community.grafana.com/t/how-to-connect-streaming-data-source-to-websocket/54927)

I would be glad to have any ideas or documentations to read about Loki storing Images.  
Thanks for Helping if you can do it !

---

<div class="post-metadata">

**Author:** ![Kinorii](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/kinorii/32/23259_2.png) [@Kinorii](https://community.grafana.com/u/Kinorii)\
**Post date:** [May 18, 2022, 11:24am UTC](https://community.grafana.com/t/displaying-images-from-python-scripts/65767/2 "2022-05-18T11:24:44Z")

</div>

I managed to do what I wanted to do using Grafana Loki and logs.

Was not quite hard after I understood how Loki ( and promtail ) was working.
