Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Fitness Insights Dashboard V1




As a motivator to maintain a healthy diet and to get into a routine of daily workouts, I have started to track my intake and exercise habits using MyFitnessPal and other mobile applications. Pulling data from those sources and creating custom events in New Relic Insights allows me to keep track of my progress and provides a way for me to query my data using NRQL and to create visualisations.

Data Sources

The two main applications I use for tracking is MyFitnessPal and MapMyWalk. MyFitnessPal allows you to track your diet and exercise to determine optimal caloric intake and nutrients for your overall goal. MapMyWalk allows you to track cardiovascular activities such as running, walking and even stationary bike exercises.

Although MyFitnessPal does have an API, it is private-access only. To get around this, I found a Python library called python-myfitnesspal which allows you to scrape your data from MyFitnessPal. See the example below:

import myfitnesspal

client = myfitnesspal.Client('my_username')
day = client.get_date(2013, 3, 2)
# >> <03/02/13 {'sodium': 3326, 'carbohydrates': 369, 'calories': 2001, 'fat': 22, 'sugar': 103, 'protein': 110}>

For a daily summary of your nutrition information, you can use a Day object’s totals property:

# >> {'calories': 2001,
#     'carbohydrates': 369,
#     'fat': 22,
#     'protein': 110,
#     'sodium': 3326,
#     'sugar': 103}

If you want to see the amount of water you’ve recorded:

# >> 1

Perfect. These are exactly the data points I am interested in. So, once a day, I call the API to get those values and record a custom event using the Python Agent API:

def send_intake_data():
    client = myfitnesspal.Client(USERNAME, PASSWORD)
    day = client.get_date(
    totals = day.totals
    totals.update({'water': day.water})
    newrelic.agent.record_custom_event('Meal', totals, application)

Similarly to MyFitnessPal, MapMyWalk does have an API but it is private access only. To address this issue, I wrote a simple script using Selenium which logs into the MapMyWalk website and then goes to a JSON resource which holds my workout data. Once every day, I call this script to get workout data for that day and then record a custom event in Insights:

def login():"Logging into MapMyWalk")
    driver = webdriver.Chrome(options=chrome_options)
    return driver

def get_workout_data():
    d = login()
    today =
    d.get(WORKOUTS % (today.month, today.year))
    pre = d.find_element_by_tag_name("pre").text
    data = json.loads(pre)"JSON response: %s" % data)
    wd = data['workout_data']['workouts']
    today = str(today)
    if today not in wd:"No workouts found for today.")
        return None
        return wd[today]

def send_workout_data():
    workout_data = get_workout_data()
    if workout_data is not None:
        for w in workout_data:
            newrelic.agent.record_custom_event('Workout', w, application)

You can find the complete source code on my GitHub. The documentation covers project setup and deployment instructions.

Insights Dashboard

Future Work

Currently the program sends data to Insights every night at 23:30pm. An improvement would be to send data at regular intervals. That would open up new possibilities such as being able to monitor my intake throughout the day. I could also setup alerts for a given condition such as if my carbohydrate intake has reached a given daily limit.

As more data is sent to Insights, I can create new visualisations such as being able to compare last weeks data to this week.

If you have any other suggestions please let me know! :slight_smile:


@abloomer Great Idea. What do you think about graphs per metric that you track and visualizing them against your personal threshold:

SELECT sum(sugar), 60 FROM Meal SINCE 1 week ago TIMESERIES 1 day

This would plot a graph that displays all daily sugar consumption against your threshold of 60 per day, and you’d see how “good” you are respective to your goal.


That’s a great idea. I’m going to add that to the dashboard. Thank you!