About 2 months ago, I decided I was tired of how much I weighed and would do something about it. I went to see my doctor and got a referral to a nutritionist who recommended I start counting calories using the Lose It! app.
Now you’re probably saying, “This is a tech blog, why are you talking about weight loss?”; hang on, I’ll get there.
I started using the Lose It! app and immediately noticed it was not great for data-minded people. The app works well for logging data and counting calories (and other macro-nutrients) but has problems if you want to do any data manipulation. Let me show you what I mean;
This is the main webpage of the Lose It! service. It’s elementary. There’s no actual data you can use; you can’t even search for information from previous days.
Imagine you want to go back and say, “What day did I have that hamburger on? And what else did I eat with it?”. Or let’s take it a step further and say that you want to ask detailed questions about your data, such as “Over the last week, what items have I eaten that had more than 10g of protein while also having less than 3g of Fat?”
Neither the Lose It! app nor the website allows this type of detailed querying and filtering of your data. You can get some basic graphs that showcase how your macros break down each day or weekly, but nothing like the questions I asked above. I’m a nerd, though, and I decided to use technology to answer these questions.
I love Splunk. I’ve used it for years, from monitoring firewall logs to tracking finances. Today I was going to use it to track my nutrition information. One fantastic thing that Lose It! offers is daily logs of your data in a csv file. Splunk has excellent parsers for csv files and no issues parsing through the data.
Furthermore, you can drill down into answering the questions I asked above through specific Splunk filters.
Once again, Splunk does a fantastic job handling this data to answer my questions. The only issue was getting the data into Splunk.
Automating the Ingest
Splunk has several ways to handle ingesting data. Still, the one I’m going to have it monitor a specific folder on my laptop for changes and then automatically upload that data to Splunk. This, however, presents a problem as it means I need to add those files to the folder on a specific machine for Splunk to find them.
This is where OneDrive comes in. Using OneDrive’s built-in file syncing, I can upload the file from anywhere to the OneDrive folder, which will automatically be downloaded to my laptop in the appropriate location.
At first, this was all I was doing; every morning, when Lose It! emailed me the logs, I would grab them on my phone and upload them to OneDrive. However, I quickly noticed records weren’t appearing in Splunk on the days I did this. It took me a minute to realize that when my phone uploaded them to OneDrive, it converted them into an xlsx file instead of a csv. This conversion broke my Splunk parsing.
So after that, I decided that once a week, I would go through and take all the data over the last week and download the logs to my computer directly so they wouldn’t convert. This was cumbersome, and I got bored with it after 2 weeks.
I needed a way to automate this. And that’s where Microsoft Power Automate came in clutch.
For those who don’t know, Power Automate is like a massively powerful IFTT with massive connectors and flexibility.
Using the above “code,” Power Automate will automatically monitor my emails for any emails from Lose It! with the subject line “Daily Summary.” Then it will take the attachment from those emails and automatically upload it to the OneDrvie directory. My laptop will then download those files automatically, and Splunk will automatically upload them for me to search.
Why did I do this? Because I like data and want to be able to manipulate it. Manually downloading and uploading csv files was annoying, and there’s the golden phrase in IT.