Giter VIP home page Giter VIP logo

strava-datasource's Introduction

Strava datasource for Grafana

Visualize your sport activity with Grafana.

Strava Dashboards

Features:

  • Query activities stats and present it as a time series data.
  • Table format.
  • Show activities over the world with Geomap Panel.
  • Visualize and analyze activity data such as heart rate, speed/pace, power, etc.
  • Template variables support.

Configuration

In order to start using Strava datasource you will need to make a Strava API application.

  1. After you are logged in, go to https://www.strava.com/settings/api and create an app.
  2. Fill out the form fields:
    • Application name: pick any name you want, ie "grafana data source".
    • Category: choose app category, for example, "Visualizer".
    • Club: select a club if you want to associate app with a particular club.
    • Website: set to anything you want, it's used primarily for publicly available apps.
    • Application Description: add description if you want
    • Authorization Callback Domain: set it to domain you're using to access Grafana. If you're using Grafana at localhost, you can put anything here, localhost and 127.0.01 are white-listed. If you're running plugin at Grafana Cloud, set it to your cloud instance domain, ie myorg.grafana.net. If you're accessing grafana via IP-address, ie 192.168.1.10, set callback domain to that address.
  3. You should see the “My API Application” page with Client ID, Client Secret and Refresh token and other information.

Learn more about Strava API applications at Strava developer docs.

Enable externalServiceAccounts feature

Plugin requires externalServiceAccounts feature toggle to be enabled. It could be done in config file:

[feature_toggles]
externalServiceAccounts = true

or through ENV variables:

services:
  # Grafana
  grafana:
    image: grafana/grafana:latest
    ports:
      - "3000:3000"
    environment:
      - GF_INSTALL_PLUGINS=grafana-strava-datasource
      - GF_FEATURE_TOGGLES_ENABLE=externalServiceAccounts

Then go to grafana and create new Strava datasource.

New Data Source

Set desired data source name and fill Client ID and Client Secret fields with values obtained from Strava API application page. Save data source configuration (you'll get an error, but it's ok since data source not authorized yet). Then click Connect with Strava button and authorize grafana datasource to connect to Strava.

Authorize datasource

If you get redirect_uri invalid error after clicking Connect with Strava, that means Authorization Callback Domain not properly configured. Get back to the Strava API application config and make sure you set it to exactly the same domain you use to open Grafana in your browser.

You will be redirected back to the datasource configuration page. Click Save & Test button and if connection is properly configured, you will see Data source is working message.

Save & Test

Now you can create some dashboards! Also, you can import dashboards from the Dashboards tab at the data source configuration page.

Importing dashboards

Once data source is configured, you can import pre-configured dashboards from Dashboards tab at the data source configuration page. That's a good starting point for your own custom dashboards.

Unfortunately, Strava API has some limitations and you can query only your own activities. But for multi-user dashboards you can configure multiple data sources and authorize separate users for each of them.

Some included dashboards depend on Grafana's new version of the panels or features which can be in alpha state in Grafana. If you want to enable alpha panels and avoid seeing an error message in the dashboard, set GF_PANELS_ENABLE_ALPHA environment variable to true. Example:

export GF_PLUGINS_ENABLE_ALPHA=true

or add config options to grafana.ini:

[panels]
enable_alpha = true

Advanced

Cache TTL

Plugin uses cache on the backend to store information of activities. This helps to reduce API usage and prevent rate limiting. Plugin basically caches everything except the list of activities on the "Strava Athlete Dashboard" (those activities cached, but with the short non-configurable interval). So if you updated activity information in Strava (ie, name, gear, etc), you don't see updates in Grafana until cache is refreshed. You can manually reset cache by clicking Save and Test button at the data source config page.

Forward OAuth identity

It's possible to configure Grafana to authenticate users with Strava and then pass through OAuth identity to the data source. This makes it possible for users to see its own data on dashboards without creating new data source for each user. To enable Strava authentication, add this section to the grafana config file:

[auth.generic_oauth]
name = Strava
icon = signin
enabled = true
allow_sign_up = true
client_id = YOUR_APP_CLIENT_ID
client_secret = YOUR_APP_CLIENT_SECRET
scopes = activity:read_all
# Strava does not expose user's email, so use username to prevent error
email_attribute_path = username
login_attribute_path = username
name_attribute_path = join(' ', [firstname, lastname])
auth_url = https://www.strava.com/oauth/authorize
token_url = https://www.strava.com/api/v3/oauth/token
api_url = https://www.strava.com/api/v3/athlete

Restart grafana server, then activate Forward OAuth Identity toggle in data source config and press Save and test button.

strava-datasource's People

Contributors

agnestoulet avatar alexanderzobnin avatar aplathan avatar jontg avatar katebrenner avatar peterholmberg avatar quentinlegay avatar rbuder avatar srclosson avatar yihong0618 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

strava-datasource's Issues

Show Heart Rate

Can the heart rate also be displayed in Grafana?
If this is not yet possible, I would like to make this suggestion that Strava's heart rate is also read out to Grafana.

So that the minimum, average and maximum heart rate can be displayed for the individual activities.

A detailed view of the individual activities would be difficult to implement in Grafana.

ARM Build instructions

Mar 23 00:05:34 locky grafana-server[1269]: t=2020-03-23T00:05:34+0100 lvl=eror msg="Failed to start plugin" logger=plugins.backend pluginId=grafana-strava-datasource error="fork/exec /var/lib/grafana/plugins/grafana-strava-datasource/dist/strava-plugin_linux_arm: no such file or directory"

why is looking inside of dist/ for a architecture for that there is no build?

Plugin doesn't have compiled binaries for arm arch. If you want to run it with Raspberry Pi, you should build it for this arch first.

but how is the question?

I just tried that from here:


root@locky:/media/locky/grafana/plugins/grafana-strava-datasource# yarn install --pure-lockfile
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.yarnpkg.com/@icons/material/-/material-0.2.4.tgz: ESOCKETTIMEDOUT".
info If you think this is a bug, please open a bug report with the information provided in "/media/locky/grafana/plugins/grafana-strava-datasource/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
root@locky:/media/locky/grafana/plugins/grafana-strava-datasource# yarn install --pure-lockfile
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The engine "node" is incompatible with this module. Expected version "^8.16.0 || ^10.6.0 || >=11.0.0". Got "8.10.0"
[3/4] Linking dependencies...
warning "@grafana/runtime > @grafana/ui > @grafana/slate-react > [email protected]" has unmet peer dependency "slate-react@>=0.22.0".
[4/4] Building fresh packages...
Done in 400.01s.
root@locky:/media/locky/grafana/plugins/grafana-strava-datasource# yarn build
yarn run v1.22.4
$ webpack --config webpack/webpack.prod.conf.js
Hash: 0679b57eef11404f4828
Version: webpack 4.41.5
Time: 29353ms
Built at: 03/23/2020 12:51:09 AM
                                         Asset       Size  Chunks             Chunk Names
                                  CHANGELOG.md  484 bytes          [emitted]
                                     README.md   1.38 KiB          [emitted]
       dashboards/strava_athlete_dashboad.json   14.6 KiB          [emitted]
dashboards/strava_athlete_dashboad_modern.json   14.9 KiB          [emitted]
             dashboards/strava_datasource.json   8.78 KiB          [emitted]
         img/btn_strava_connectwith_orange.svg   11.3 KiB          [emitted]
                           img/strava_logo.svg  291 bytes          [emitted]
                                    index.html  182 bytes          [emitted]
                                     module.js   25.4 KiB       0  [emitted]  main
                                   plugin.json   1.24 KiB          [emitted]
Entrypoint main = module.js
[0] external "react" 42 bytes {0} [built]
[1] external "@grafana/ui" 42 bytes {0} [built]
[2] external "@grafana/data" 42 bytes {0} [built]
[3] external "emotion" 42 bytes {0} [built]
[4] external "@grafana/runtime" 42 bytes {0} [built]
[5] external "moment" 42 bytes {0} [built]
[6] ./module.tsx + 7 modules 53.4 KiB {0} [built]
    | ./module.tsx 670 bytes [built]
    | ./datasource.ts 16 KiB [built]
    | ./types.ts 1.15 KiB [built]
    | ./stravaApi.ts 12.4 KiB [built]
    | ./polyline.ts 1.18 KiB [built]
    |     + 3 hidden modules
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
       3 modules
Done in 34.40s.

but no binary created inside of dist/ . In fact, the other binaries inside of /dist were deleted.

Any suggestion how to compile the "strava-plugin_linux_arm" binary?

401 errrors version 1.51.

As per #62

I'm still seeing 401 errrors - Google cloud, plugin 1.5.1

Tried multiple removals and reconfigurations. No change.

Auth error

i try to connect to strava but get always an error.
{"message":"Bad Request","errors":[{"resource":"Application","field":"redirect_uri","code":"invalid"}]}

Include Distance as Miles

I see that the default API brings in the data as kilometers. My Strava dashboard is setup for miles, but apparently that is only for my account and not the API data. I tried to change the data units to miles in Grafana but if I ride for instance 11.45km and this shows up on my dashboard. If i change the units to miles it will just make it 114450 miles instead of converting it over to 7.11 miles. I have not found anyway to have it display in miles thus far and wonder how those living in the US can get this to show in miles.

Refresh token not found, authorize datasource first

Strava Plugin 1.2.0

Added client ID and Secret but errors out
t=2020-12-26T11:51:27+0000 lvl=eror msg="open /4-refreshToken: no such file or directory" logger=plugins.backend pluginId=grafana-strava-datasource
t=2020-12-26T11:51:27+0000 lvl=eror msg="Strava API request error" logger=plugins.backend pluginId=grafana-strava-datasource error="Refresh token not found, authorize datasource first"
t=2020-12-26T11:51:27+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/4/resources/strava-api status=500 remote_addr=192.168.8.121 time_ms=29 size=97 referer=http://192.168.8.240:3000/datasources/edit/4/
t=2020-12-26T16:27:49+0000 lvl=eror msg="open /4-refreshToken: no such file or directory" logger=plugins.backend pluginId=grafana-strava-datasource
t=2020-12-26T16:27:49+0000 lvl=eror msg="Strava API request error" logger=plugins.backend pluginId=grafana-strava-datasource error="Refresh token not found, authorize datasource first"
t=2020-12-26T16:27:49+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/4/resources/strava-api status=500 remote_addr=192.168.8.121 time_ms=28 size=97 referer=http://192.168.8.240:3000/datasources/edit/4/

Single Activity Map?

Is it possible to show the route, or even starting location for a single activity on the worldmap? I tried playing with the worldmap plugin on my datasource but just ended up blowing my request limit. Would be nice to filter through activities, clicking on a specific one to see where it was

Strava datasource cannot connect to Strava API - Bad Request or 401 Unauthorized

I installed strava plugin into Grafana. I tried to configure datasource with both options OAuth and Refresh token, bot none of them works.

OAuth

image

When I press Connect with STRASVA, new tab is opened with error:

{
  "message": "Bad Request",
  "errors": [
    {
      "resource": "Application",
      "field": "redirect_uri",
      "code": "invalid"
    }
  ]
}

Refresh token

image

This option show information, that Data source is working.

When I open New Dashboard and switch to my Strava datasource, I receive immediately 401 error:

image

From Strava API dashboard I can see, api calls have been made:
image

Grafana 8.0

The plugin seems not to be compatible with Grafana 8.0. The "connect with Strava" button produces a 404.
Best C.

Refresh token not found error

Hi,

This looks to be a great plugin but I am having trouble connecting to the Strava API.

I am running a grafana server locally in a docker container but I am getting the following error:

Refresh token not found, authorize datasource first

I have done the following:

  • Install the plugin in the docker container with the following command grafana-cli plugins install grafana-strava-datasource
  • Restart the docker container
  • Create a directory /var/lib/grafana/strava
  • Define an environment variable export GF_STRAVA_DS_DATA_PATH=/var/lib/grafana/strava/
  • Add a datasource specifying the Client ID and Client Secret from an app created in my Strava account
  • I get the following messages

image

Do you know how I can solve this issue please?

Error configuring datasource

Hello there,

After filling out my Strava ClientID and connect with Strava I get redirected. When I allow my Strava APP I get redirected back to Grafana but all fields are empty. When hitting Save & Test I get the error: Cannot connect to Strava API

My Logs show:

t=2020-05-28T13:37:59+0200 lvl=eror msg="Metric request error" logger=context userId=1 orgId=1 uname=admin error="rpc error: code = Unknown desc = Refresh token not found, authorize datasource first"
t=2020-05-28T13:37:59+0200 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/tsdb/query status=500 remote_addr=192.168.3.14 time_ms=6 size=34 referer="http://grafana.rb.lab/datasources/edit/7/?state=&code=aece2c63586295835f4cfa5f2e4e2a0be0a7a3ee&scope=read,activity:read_all,profile:read_all,read_all"

What is going wrong here?

401 Unauthorized in Dashboards / Explore

I'm consistently getting a 401 Unauthorized in Dashboards and Explore (see attached photo), however, I am able to configure the plugin and it correctly authenticates me. It's a local Grafana install, if that matters. Sorry, I'm somewhat new to Grafana so I'm not sure how to debug or provide the error responses from the Strava API (or queries it's sending out), but am happy to post those if you can explain how I do that.

Explore View:
image

Datasource Settings:
image

Configuration Errror - "Cannot connect to Strava API"

I am having issues getting the Strava datasource to work properly. When saving and testing the datasource, this happens:
image

Related messages from the Grafana server log

t=2020-03-11T15:58:46+0000 lvl=eror msg="Metric request error" logger=context userId=1 orgId=1 uname=admin error="Could not find executor for data source type: grafana-strava-datasource"
t=2020-03-11T15:58:46+0000 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/tsdb/query status=500 remote_addr=10.0.0.17 time_ms=5 size=34 referer="http://10.0.0.100:3000/datasources/edit/3/?state=&code=<INSERT_CODE_HERE>&scope=read,activity:read_all,profile:read_all,read_all"

Grafana Version: Version 6.6.2 (commit: 3fa63cfc34, branch: HEAD)

Any help would be greatly appriciated!

Geomap and link

In a geomap, it seems impossible to link a marker of an activity to a specific activity. I tried with different layers, queries, and so on. But I can't get the ${__data.fields.id} while being in a geomap query.
Any clue? Thanks for your amazing work.

Cannot connect to Strava API

Hi,

I have problems connecting to Strava API. The second screenshot shows the error message upon clicking 'Connect to Strava'. Am I doing anything wrong, I have installed Strava plugin on Grafana and initiated an api application on Strava. WIll appreciate any help on this!
image
image

Average speed / Pace in "Activities" query

Hey 🖖 I'm wondering why I can select the "Average Speed" (Pace) in the "Activities" query when using the format "Table" only. Is there a reason why this information isn't available when using the format "Time series"?

Screenshot-Edit panel - BikeStats (Strava) - Strava - Dashboards - Grafana-Arc-20240215_1458@2x

401 Unauthorized - by connecting to Strava API

After updating the version from 1.3 to 1.5 I'm not able to connect to Strava API anymore.

I always get the error message: "Cannot connect to Strava API: Token exchange failed: 401 Unauthorized" by clicking "Save & Test" in the "Data Source / Strava" section.
And a short message appears: "Token exchange failed"

I also updated the parameter GF_STRAVA_DS_DATA_PATH as mentioned in the plugin description (and made the folder readable for grafana). But without any success.

In the logfile by restarting the grafana server these messages appear (don't know if this is the problem ... ) :
"Could not read environment variable" variable=GF_STRAVA_DS_DATA_PAT"
"Using default data path" path=/usr/share/grafana/.cache/strava-datasource"

With version 1.3 everything was ok.

Thank you for your support

refreshtoken and make Dashboards moveable

Thanks for your work. But two wishes:

  1. It started working after I putting my refreshtoken manually into an 1-refreshToken file under /var/lib/grafana/strava-datasource/ . I am using kube-prometheus-stack which runs grafana inside a container.

image

  1. I have many many dashboards. That's why I organize them into subfolders. I really would appreciate it if I could move the dashboards into a strava subfolder.

Thanks

Gerd

Readme

Add some plugin description with features.

Strava Developer program changes

There's a change in terms of usage for API recently introduced by Strava team. In order to continue use API for applications, you need to apply for the review of your app. Fortunately, if you only use it for your own data, you'll get "Single Player Mode" automatically. That fits purpose of the plugin in most use cases. However, if you want to run plugin and authenticate multiple users, form submission is required. You can read more about new terms here https://communityhub.strava.com/t5/developer-knowledge-base/our-developer-program/ta-p/8849

Issue with configuring Strava datasource in Grafana

Hello All,

im getting an error while configuring a Strava datasource in Grafana as Refresh token not available, authorize datasource first message. I tried to follow some of existing issue to understand the problem but it didnt helps as one of the recommendation given to use callback domain in strava as IP address but it didnt help. please find below Grafana logs and help me how to get it sorted. Thanks in advance.

remote_addr=192.168.0.101 time_ms=7 size=26 referer=http://192.168.0.101:3000/login
t=2021-05-28T19:29:10+0530 lvl=info msg="Successful Login" logger=http.server User=admin@localhost
t=2021-05-28T19:29:39+0530 lvl=eror msg="Strava API request error" logger=plugins.backend pluginId=grafana-strava-datasource error="Auth error, status: 401 Unauthorized"
t=2021-05-28T19:29:39+0530 lvl=eror msg="Request Completed" logger=c2ontext userId=1 orgId=1 uname=admin method=POST path=/api/datasources/1/resources/auth status=500 remote_addr=192.168.0.101 time_ms=1283 size=82 referer="http://192.168.0.101:3000/datasources/edit/1/?state=&code=7b93f555988d0f97c411872960ef05bbc4df7e5a&scope=read,activity:read_all,profile:read_all,read_all"
t=2021-05-28T19:29:39+0530 lvl=eror msg="open /1-refreshToken: The system cannot find the file specified." logger=plugins.backend pluginId=grafana-strava-datasource
t=2021-05-28T19:29:39+0530 lvl=eror msg="Strava API request error" logger=plugins.backend pluginId=grafana-strava-datasource error="Refresh token not found, authorize datasource first"
t=2021-05-28T19:29:39+0530 lvl=eror msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=POST path=/api/datasources/1/resources/strava-api status=500 remote_addr=192.168.0.101 time_ms=3 size=97 referer="http://192.168.0.101:3000/datasources/edit/1/?state=&code=7b93f555988d0f97c411872960ef05bbc4df7e5a&scope=read,activity:read_all,profile:read_all,read_all"

Raspberry Pi Compatibility

Hi!

Just wanted to say this dashboard is great and I have been trying to move my monitoring to a raspberry pi and unfortunately this just doesn't seem to want to work.

Do you think there will ever be support for this?
I have tried raspbian and Ubuntu server and get the below error when I try and perform the 2nd verification step

Screenshot 2020-04-23 at 14 03 32

I tried the same account on a fresh version of Ubuntu on the PC and it seems to work
Any help would be greatly appreciated

connection problems

the connection problems stays.
i´m getting this error:
{"message":"Bad Request","errors":[{"resource":"Application","field":"redirect_uri","code":"invalid"}]}

Datasource provisioning

Hello folks! Thank you for all the work on this plugin.

Is there a way to provision the strava datasource as described in the Grafana documentation? I took a look at the plugin.json file but could not figure out the correct values for provisioning the datasource.

Grafana 5.3.0 and Debian 9 Stretch

Hello followed the configuration instructions, making the folder and adding the environment variable to my grafana.ini file. Then installed the plugin via the grafana-cli tool. When I try to add a Strava data source I get the error shown below.

"Plugin Error
Fetch error: 404 Not Found Instantiating http://XX.XX.XX.XX:3000/public/@grafana/ui Loading http://XX.XX.XX.XX:3000/public/plugins/grafana-strava-datasource/module.js Loading plugins/grafana-strava-datasource/module"

Grafana

Do I just need to upgrade my Grafana install? I am pretty new to Linux, may have missed a permission or other web server configuration. Thanks for this AWESOME plugin, looking forward to getting it running.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.