Measurement Mappings

Connecting customers with measurements.

🚧

This is an advanced topic

Most use cases of measurements don't require Measurement Mappings. If you think you might not need them, you're probably right. If you aren't sure, you can always get in touch with your support representative.

Attributing measurements to customers

By default, Measurements are associated to customers by setting the customer_name field on the measurement. For more flexibility, we also support complex associations to a customer through flexible mappings.

Mappings work by identifying labels and values to match a measurement on. Each mapping has a customer name, a label name and a "value regex". We look for any measurement that has that label, see if its value matches the value regex, and associate that measurement to the given customer.

Here is an example of adding a customer mapping for customer_1 to match any measurements where the label "user_id" equal "id_1".

import octane
octane.api_key = "vendor_api_key_abcdefg"

octane.Customer.create_mapping(
  "customer_1",
  label="user_id",
  value_regex="id_1"
)
import Octane from "octane-node";
const octane = new Octane("<YOUR_API_KEY>");

octane.customers.createMapping("customer_1", {
  label: "user_id",
  valueRegex: "id_1"
});
package main

import "github.com/getoctane/octane-go"

func main() {
  client := octane.NewClient("<YOUR_API_KEY>")
  
  args := octane.CustomerMeasurementMappingInputArgs{
    Label:      "user_id",
    ValueRegex: "id_1",
  }
  
  _, _, err := client.Customers.CreateMapping("customer_1", args)
  if err != nil {
    panic(err)
  }
}

Using POSIX regex

Octane treats the specified value in the customer mappings as a POSIX regex for matching. This allows matching a pattern rather than exact string. For example, we may have a meter for file storage consumption that includes a "filepath" label. We can map a customer to all measurements for a given directory by providing a wildcard (.*) in the value for the "filepath" label.

import octane
octane.api_key = "vendor_api_key_abcdefg"

octane.Customer.create_mapping(
  "customer_1",
  label="filepath",
  value_regex="/root/dir/customer-1/.*"
)

Matching on multiple labels

We can set up the customer mapping to match on multiple labels. A measurement will only be attributed to a customer if all of the labels and values match the mapping. In this example, only measurements with "prod-customers" as the "cluster" label and "customer-1" as the "namespace" label will be attributed to "customer_1".

import octane
octane.api_key = "vendor_api_key_abcdefg"

octane.Customer.create_mapping(
  "customer_1",
  label="cluster",
  value_regex="prod-customers"
)
octane.Customer.create_mapping(
  "customer_1",
  label="namespace",
  value_regex="customer-1"
)

Next Steps