Dimensions

You can add Dimensions to your data items. Any property string that does not start with ‘$’ (reserved for metric key identifiers) and is not equal to ‘date’ or ‘unit’ will be recognized as a dimension.

In the example below, we’ve split the metric up based on the Dimension ‘Channel.’

  • cURL
  • PHP
  • JavaScript
  • Ruby
  • Java
  • Go
  • Python
curl https://push.databox.com \
-u <your_token>: \
-X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.databox.v2+json' \
-d '{
  "data":[
    {
      "$sales": 83000,
      "channel": "online"
    },
    {
      "$sales": 4000,
      "channel": "retail"
    },
    {
      "$sales": 123000,
      "$expenses": 87500,
      "channel": "in-person"
    }
  ]
}'
use Databox\Client;

$c = new Client('<your_token>');

$c->insertAll([
    ['sales', 83000, null, [
      'channel' => 'online'
    ]],
    ['sales', 4000, null, [
      'channel' => 'retail'
    ]],
]);
var Databox = require('databox');

var client = new Databox({
    push_token: '<your_token>'
});

client.insertAll([
  {
    key: 'sales',
    value: 83000,
    attributes: {
      'channel': 'online'
    }
  },
  {
    key: 'sales',
    value: 4000,
    attributes: {
      'channel': 'retail'
    }
  }
]);
Databox.configure do |c|
  c.push_token = '<your_token>'
end

client = Databox::Client.new

client.insert_all [
    {key: 'sales', value: 83000, attributes: {
      channel: 'online'
    }},
    {key: 'sales', value: 4000, attributes: {
      channel: 'retail'
    }}
]
String TOKEN = "<your_token>";
Databox databox = new Databox(TOKEN);
try {
  List<Databox.KPI> kpis = new ArrayList<Databox.KPI>();
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
  kpis.add(new Databox.KPI().setKey("sales").setValue(83000).addAttribute("channel", "online"));
  kpis.add(new Databox.KPI().setKey("sales").setValue(4000).addAttribute("channel", "retail"));
  databox.push(kpis);
} catch (Exception e) {
  System.err.println(e.getLocalizedMessage());
}
package main

import (
    databox "github.com/databox/databox-go"
    "fmt"
)

func main() {
    client := databox.NewClient("<your_token>")

    var attributes = make(map[string]interface{})
    attributes["channel"] = "online"

    if _, error := client.Push(&databox.KPI{
        Key: "sales",
        Value: 83000,
        Attributes: attributes,
    }); error != nil {
        fmt.Println("Inserted.")
    }
}
from databox import Client

client = Client('<your_token>')
client.insert_all([
    {'key': 'sales', 'value': 83000, 'attributes': {
      'channel': 'online',
    }},
    {'key': 'sales', 'value': 4000, 'attributes': {
      'channel': 'retail',
    }},
])

Pro Tip: If you send one Dimension with multiple metrics, the dimension will be added to each metric.

In Databox, you can filter and visualize your data for specific dimensions. That means you could view only retail sales, or compare sales across different channels. You can add as many dimensions as you’d like to each metric.

Next step: Units