Visualize data

Once you have used the data management service to capture data, you can visualize your data using

Teleop dashboard

Create a dashboard to visualize data for machines in your organization.

Prerequisites

A machine with at least one sensor, camera, or other component that captures data

Make sure your machine is configured with at least one component that can capture data, for example:

Create a workspace

  1. Navigate to the FLEET page’s TELEOP tab. Click + Create workspace.

  2. Enter a unique name for your workspace in the top left of the page, replacing the placeholder untitled-workspace text.

  3. Use the Select location dropdown to select the location that contains the machine that you would like to visualize data from.

  4. Use the Select machine dropdown to select the machine that you would like to visualize data from.

Add a widget

  1. Click Add widget and select a widget type to create a new widget on your workspace.

    See widget types for more information about each type.

  2. To configure the widget, click the pencil icon in the top right of your widget:

    Click the pencil icon to configure your widget.

You can mix and match multiple widgets to visualize many kinds of data collected by your machine:

Workspace containing multiple widgets displaying sensor data visualizations.

To arrange widgets on your workspace, click and drag the grid icon in the top left of your widget:

Click the grid icon to move a widget.

Third party tools

When you sync captured data to Viam, that data is stored in a MongoDB Atlas Data Federation instance. You can use third-party visualization tools, such as Grafana, to connect to it and visualize your data, as long as the tool supports MongoDB Atlas Data Federation as a data store.

To use a third-party visualization tool like Grafana to visualize your data, you must first configure data query.

Prerequisites

Captured sensor data. Click to see instructions.
Follow the docs to capture data from a sensor.
The Viam CLI to set up data query. Click to see instructions.

You must have the Viam CLI installed to configure querying with third-party tools.

To download the Viam CLI on a macOS computer, install brew and run the following commands:

brew tap viamrobotics/brews
brew install viam

To download the Viam CLI on a Linux computer with the aarch64 architecture, run the following commands:

sudo curl -o /usr/local/bin/viam https://storage.googleapis.com/packages.viam.com/apps/viam-cli/viam-cli-stable-linux-arm64
sudo chmod a+rx /usr/local/bin/viam

To download the Viam CLI on a Linux computer with the amd64 (Intel x86_64) architecture, run the following commands:

sudo curl -o /usr/local/bin/viam https://storage.googleapis.com/packages.viam.com/apps/viam-cli/viam-cli-stable-linux-amd64
sudo chmod a+rx /usr/local/bin/viam

You can also install the Viam CLI using brew on Linux amd64 (Intel x86_64):

brew tap viamrobotics/brews
brew install viam

Download the binary and run it directly to use the Viam CLI on a Windows computer.

If you have Go installed, you can build the Viam CLI directly from source using the go install command:

go install go.viam.com/rdk/cli/viam@latest

To confirm viam is installed and ready to use, issue the viam command from your terminal. If you see help instructions, everything is correctly installed. If you do not see help instructions, add your local go/bin/* directory to your PATH variable. If you use bash as your shell, you can use the following command:

echo 'export PATH="$HOME/go/bin:$PATH"' >> ~/.bashrc

For more information see install the Viam CLI.

Configure data query

Configuring data query will provide you with the credentials you need to connect to your data using a compatible client such as mongosh, Grafana, or a third-party visualization service.

1

Authenticate with the CLI

Authenticate using a personal access token:

viam login

For alternative authentication methods, see Authenticate.

2

Find your organization ID

The following steps require your organization ID. To find, it use the following command:

viam organizations list
3

Configure a new database user

Configure a new database user. The database user will be able to connect to your data, which is stored in a MongoDB Atlas Data Federation instance.

Provide your organization’s org-id from step 2, and a password for your database user. Your password must be at least 8 characters long with 1 uppercase, and 1 numeric character.

viam data database configure --org-id=<YOUR-ORGANIZATION-ID> --password=<NEW-DBUSER-PASSWORD>
4

Determine the connection URI

Determine the connection URI (also known as a connection string) for your organization’s MongoDB Atlas Data Federation instance by running the following command with the organization’s org-id from step 2:

viam data database hostname --org-id=abcd1e2f-a1b2-3c45-de6f-ab123456c123

MongoDB Atlas Data Federation instance hostname: data-federation-abcd1e2f-a1b2-3c45-de6f-ab123456c123-0z9yx.a.query.mongodb.net
MongoDB Atlas Data Federation instance connection URI: mongodb://db-user-abcd1e2f-a1b2-3c45-de6f-ab123456c123:YOUR-PASSWORD-HERE@data-federation-abcd1e2f-a1b2-3c45-de6f-ab123456c123-0z9yx.a.query.mongodb.net/?ssl=true&authSource=admin

This command returns the:

  • hostname: the MongoDB Atlas Data Federation instance hostname

  • connection URI: the MongoDB Atlas Data Federation instance connection uniform resource indicator. This is the connection URI to your organization’s MongoDB Atlas Data Federation instance, which is of the form:

    mongodb://<USERNAME>:<YOUR-PASSWORD>@<HOSTNAME>/?ssl=true&authSource=admin
    

Most MQL-compatible database clients require the connection URI, along with your user credentials, to connect to this server.

Some MQL-compatible database client instead require a hostname and database name, along with your user credentials, to connect to this server. For sensor data, this database name will be sensorData.

Visualize data with third-party tools

You can use the connection information you obtained when configuring data query with any third-party tool that supports MongoDB Atlas Data Federation as its data store.

Once connected, you can visualize captured sensor readings as well as any other time-series data, including metadata such as machine ID, organization ID, and tags.

Below are the steps for Grafana and for other visualization tools.

Grafana

1

Choose Grafana instance

Install or set up Grafana. You can use either a local instance of Grafana Enterprise or Grafana Cloud. The free trial version of Grafana Cloud is sufficient for testing.

2

Install connector to MongoDB data source

Navigate to your Grafana web UI. Go to Connections > Add new connection and add the Grafana MongoDB data source plugin to your Grafana instance.

The Grafana plugin search interface showing the results for a search for mongodb
3

Configure a data connection

On the page of the Grafana MongoDB data source that you just installed, select Add new data source.

Enter the following information in the configuration UI for the plugin:

  • Connection string: Enter the following connection string. Then replace <MONGODB-ATLAS-DF-HOSTNAME> with your database hostname as configured with the viam data database configure command. The <DATABASE-NAME> for sensor data is sensorData.

    mongodb://<MONGODB-ATLAS-DF-HOSTNAME>/<DATABASE-NAME>?directConnection=true&authSource=admin&tls=true
    
  • User: Enter the following username, substituting your organization ID for <YOUR-ORG-ID>:

    db-user-<YOUR-ORG-ID>
    
  • Password: Enter the password for the database user. This is the password provided when configuring data query.

    The Grafana data source plugin configuration page, showing the connection string and username filled in with the configuration determined from the previous steps

For more information on the Grafana MongoDB plugin, see Configure the MongoDB data source.

4

Use Grafana for dashboards

With your data connection established, Grafana can now access all synced sensor data under your organization, from any machine.

You can now build dashboards that provide insight into your data.

You can also query and transform your data. This way, you can visualize different things, such as:

  • a single day’s data
  • a single machine’s or component’s data
  • outliers in your data
Click here for resources on building a Grafana Dashboard.
5

Query data from Grafana

You can also use query language directly in Grafana using the MongoDB Query Editor, which enables data query functionality similar to that of the MongoDB shell, mongosh.

For example, try the following query to obtain readings from a sensor, replacing sensor-1 with the name of your component:

sensorData.readings.aggregate([
  {
    $match: {
      component_name: "sensor-1",
      time_received: { $gte: ISODate(${__from}) }
    }
  },
  { $limit: 1000 }
])

This query uses the Grafana global variable $__from, which is populated by the value set from the From dropdown menu on your dashboard. The value is dynamically updated when you change your desired time range from that dropdown menu. See Grafana’s Global variables documentation for more information.

6

Optimize your queries

For optimal performance when querying large datasets, see query optimization and performance best practices.

Other visualization tools

1

Install connector to MongoDB data source

Some visualization clients are able to connect to the Viam MongoDB Atlas Data Federation instance natively, while others require that you install and configure an additional plugin or connector. For example, Tableau requires both the Atlas SQL JDBC Driver as well as the Tableau Connector in order to successfully connect and access data.

Check with the documentation for your third-party visualization tool to be sure you have the required additional software installed to connect to a MongoDB Atlas Data Federation instance.

2

Configure a data connection

Most third-party visualization tools require the connection URI (also called the connection string) to that database server, and the credentials to authenticate to that server in order to visualize your data. Some third-party tools instead require a hostname and database name of the database server. This is what they look like:

If your client supports a connection URI, use the following format and replace YOUR-PASSWORD-HERE with your database password as configured with the viam data database configure command:

mongodb://db-user-abcdef12-abcd-abcd-abcd-abcdef123456:YOUR-PASSWORD-HERE@data-federation-abcdef12-abcd-abcd-abcd-abcdef123456-e4irv.a.query.mongodb.net/?ssl=true&authSource=admin

You can also specify a database name in your connection URI. For example, to use the sensorData database, the default database name for uploaded sensor data, your connection string would resemble:

mongodb://db-user-abcdef12-abcd-abcd-abcd-abcdef123456:YOUR-PASSWORD-HERE@data-federation-abcdef12-abcd-abcd-abcd-abcdef123456-e4irv.a.query.mongodb.net/sensorData?ssl=true&authSource=admin

If your client doesn’t use a connection URI, you can supply the hostname and database name of the database server instead.

Substitute the hostname returned from the viam data database hostname command for <MONGODB-ATLAS-DF-HOSTNAME> and the desired database name to query for <DATABASE-NAME>:

mongodb://<MONGODB-ATLAS-DF-HOSTNAME>/<DATABASE-NAME>?directConnection=true&authSource=admin&tls=true

For example, to use the sensorData database, the default name for uploaded data, your connection string would resemble:

mongodb://data-federation-abcdef12-abcd-abcd-abcd-abcdef123456-e4irv.a.query.mongodb.net/sensorData?directConnection=true&authSource=admin&tls=true

Your database user name is of the following form:

db-user-<YOUR-ORG-ID>

Substitute your organization ID for <YOUR-ORG-ID>.

3

Use visualization tools for dashboards

Some third-party visualization tools support the ability to directly query your data within their platform to generate more granular visualizations of specific data. If available, you can use this functionality to visualize different things, such as:

  • a single day’s data
  • a single machine’s or component’s data
  • outliers in your data

While every third-party tool is different, you would generally query your data using either SQL or MQL. See the guide on querying data for more information. For optimal performance when querying large datasets, see the query optimization and performance best practices section.

Error