VOOZH about

URL: https://thenewstack.io/how-i-created-a-telegraf-plugin-to-monitor-solar-panels/

⇱ How I Created a Telegraf Plugin to Monitor Solar Panels - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2019-01-23 03:00:20
How I Created a Telegraf Plugin to Monitor Solar Panels
case-study,contributed,sponsor-influxdata,sponsored,sponsored-post-contributed,tutorial,
Edge Computing / Observability

How I Created a Telegraf Plugin to Monitor Solar Panels

I managed to hook up solar panels at my house over a year ago, but soon realized I had a problem: I wanted more access to how certain metrics were displayed, such as how much power and energy the panels were able to generate from the sun. As a way to retrieve these metrics from the solar panels, I found that the Fronius solar inverter, which transforms DC electricity coming from solar panels to grid-compatible AC, has a push service
Jan 23rd, 2019 3:00am by Julius Marozas
👁 Featued image for: How I Created a Telegraf Plugin to Monitor Solar Panels
Feature image via Pixabay.
InfluxData sponsored this post.
Julius Marozas
Julius is a student at the Kaunas University of Technology Gymnasium in Lithuania. He is interested in home automation, internet of things as well as functional programming. Last year, he completed his studies at the NFQ Academy, where he improved his skills in web development. He uses Home Assistant on a Synology NAS server to make his home smarter.

I managed to hook up solar panels at my house over a year ago, but soon realized I had a problem: I wanted more access to how certain metrics were displayed, such as how much power and energy the panels were able to generate from the sun. I was also interested in correlating this data with temperature, cloudiness and sun intensity.

As a way to retrieve these metrics from the solar panels, I found that the Fronius solar inverter, which transforms DC electricity coming from solar panels to grid-compatible AC, has a push service. This push service can be configured to periodically send HTTP POST or FTP requests with the data encoded in JSON to the provided endpoint — exactly what I needed.

I was also already using the InfluxDB database for storing other metrics from IoT devices and thought that it would be cool to just persist the inverter-produced data there. However, at the time Telegraf (the official data collector software for InfluxDB) didn’t support parsing JSON (and other data formats) data sent via HTTP POST/PUT requests. As these types of requests are the de-facto standard, I decided to contribute and create a http_listener_v2 plugin which would support this use case.

Essentially, the plugin registers HTTP POST/PUT requests. The data from the request is parsed in the specified format and then forwarded to InfluxDB or other supported databases.

In this blog post, I will explain how I now am able to use the http_listener_v2 Telegraf plugin I created to record and analyze the power my house’s solar panels generate. By following along, you will learn about the basic architecture of the InfluxDB’s TICK Stack and understand how to set up the plugin yourself.

Fronius Inverter Settings

The settings of the Fronius inverter can be reached via its WiFi access point. The section that interests me is the push service. This service periodically sends data (electricity power, energy and voltage) to specified endpoints via HTTP. Here is my configuration:

👁 Image

When saved, the interface says that a connection is not possible because Telegraf is not yet listening on the specified server port. I am going to fix this in the next paragraphs.

Setting Up the TICK Stack

The easiest way to get Telegraf up and running is to use the sandbox which spins up the whole TICK Stack (Telegraf, InfluxDB, Chronograf and Kapacitor) in Docker. All components of the TICK Stack can be started by calling ./sandbox up in the command line. However, before that I need to expose port :8080 for Telegraf in the docker-compose.yml file:

telegraf:
 build:
   context: ./images/telegraf/
   dockerfile: ./${TYPE}/Dockerfile
 args:
     TELEGRAF_TAG: ${TELEGRAF_TAG}
image:"telegraf"
environment:
 HOSTNAME: "telegraf-getting-started"
links:
 - influxdb
volumes:
 -./telegraf/:/etc/telegraf/
 - /var/run/docker.sock:/var/run/docker.sock
ports:       # new lines
 - "8080:8080" # new lines
depends_on:
 -influxdb
InfluxData is the creator of InfluxDB, the leading time series platform. More than 1,900 customers use InfluxDB to collect, store, and analyze all time series data at any scale. Developers can query and analyze their time-stamped data to predict, respond, and adapt in real-time.
Learn More
The latest from InfluxData

Configuring Telegraf

In the next step, we need to configure the Telegraf server to listen for the incoming JSON data sent by the inverter.

Here’s how I set up the http_listener_v2 plugin in the Telegraf’s config:

[[inputs.http_listener_v2]]
# the name of the measurement
name_override = "solar"  

# settings for the http listener
service_address = ":8080"
path = "/fronius"
methods = ["POST"] 

# json parsing
data_format = "json"
json_time_key = "Head_Timestamp"
json_time_format = "2006-01-02T15:04:05Z07:00"  

# data filtering
fieldpass = ["Body_*"]
fielddrop = ["Body_0_Enable", "Body_0_TimeStamp", "Body_0_Visible"]

NOTE: if you’re using the sandbox, the config file should be located as telegraf/telegraf.conf (the file is in toml format). After making any changes to the config, don’t forget to restart the sandbox with ./sandbox restart.

All options for http_listener_v2 plugin can be found here.

In order to understand how the json_time_format gets interpreted, read more about the date and time parsing in this paragraph of the Go documentation.

Processing Input Data

After receiving the HTTP POST request, the http_listener_v2 plugin parses the data based on data_format option (all available formats can be found here). In my case, it’s the JSON parser. The parser flattens each JSON object into an InfluxQL query. The flattening is done by joining the JSON keys with an underscore ‘_’. For instance:

{
"Body": {
 "P_PV": 764.0,
 "P_Load": 258.0
 }
}

This JSON object is flattened to Body_P_PV=764.0, Body_P_Load=258.0.

To simplify the naming of the data fields, the processor.rename plugin can be used to drop the unnecessary prefixes in the measurement field names:

[[processors.rename]]
 namepass = "solar"  

[[processors.rename.replace]]
  field = "Body_P_PV"
  dest = "P_PV"

[[processors.rename.replace]]
  field = "Body_P_Load"
  dest = "P_Load"

Inspecting Data Series with Chronograf

Finally, we can observe the collected time series data with Chronograf. By default, Chronograf should be on localhost:8888.

It’s easy to get an overview of all of the data in the Explore tab. There you can either click through the databases, measurements, and fields or write an InfluxQL query yourself. You can also choose Flux, which is a new programming language specifically designed for working with data series. If you would like to see your visualizations sometime again, you can create a dashboard in the Dashboards tab. Check the out-of-the-box examples for inspiration.

Below is the visualization of the data sent from my solar inverter. The green line represents generated energy, and yellow represents consumed. We can clearly see that there’s not much energy generated in the middle of winter.

👁 Image

Although creating data visualizations is quick and effortless in Chronograf, you can look at Grafana for a more advanced graphics solution. It works really well with InfluxDB.

👁 Image

Conclusion

To recap, I have created a new input plugin http_listener_v2 for Telegraf and demonstrated how it was used with the Push Service of Fronius solar inverter. The JSON data from the inverter was parsed, processed and then visualized in Chronograf and Grafana.

The plugin can be used in other cases as well. It can be configured to save non-numeric values as tags or parse other data formats such as CSV.

InfluxData is the creator of InfluxDB, the leading time series platform. More than 1,900 customers use InfluxDB to collect, store, and analyze all time series data at any scale. Developers can query and analyze their time-stamped data to predict, respond, and adapt in real-time.
Learn More
The latest from InfluxData
TRENDING STORIES
Julius is a student at the Kaunas University of Technology Gymnasium in Lithuania. He is interested in home automation, internet of things as well as functional programming. Last year, he completed his studies at the NFQ Academy, where he improved...
Read more from Julius Marozas
InfluxData sponsored this post.
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Pragma, Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
👁 Image
Join the millions of developers using InfluxDB to predict, respond, and adapt in real-time.