How to Configure Y-Axis Measurement Units in Grafana for Graphite Metrics


7 views

When working with Graphite metrics in Grafana, you might encounter unexpected unit notations like "Mib" (mebibytes) or "Bil" (billions) on your Y-axis. This typically happens because:

  • Grafana automatically applies unit conversions based on metric values
  • The default unit interpretation may not match your data source's actual units
  • Graphite doesn't enforce strict unit metadata like Prometheus does

To properly display memory metrics in MB (megabytes) for your collectd data:

  1. Open your Grafana dashboard
  2. Select the problematic panel
  3. Click the Title of the panel to open the edit menu
  4. Navigate to the Field tab (left sidebar)
  5. Find the Standard options section
  6. Under Unit, select Databytes(MB)

For more control over unit display, you can use Grafana's override feature:


// Example: Force MB display for specific metrics
"overrides": [
  {
    "matcher": {
      "id": "byName",
      "options": "memory.used"
    },
    "properties": [
      {
        "id": "unit",
        "value": "bytes(MB)"
      }
    ]
  }
]

When working with collectd data in Graphite:

  • Verify your storage schema uses consistent units (check storage-schemas.conf)
  • Consider using scale() function in Grafana queries if raw values need adjustment:
    
    scale(movingAverage(collectd.*.memory.memory-used, '1min'), 1/1048576)
    
  • For memory metrics, ensure collectd is configured with proper units (usually MB)

If units still appear incorrectly:

  1. Check raw metric values in Graphite web interface
  2. Verify no unit conversion functions are applied in the query
  3. Inspect panel JSON model for hardcoded unit settings
  4. Test with a simple query to isolate the issue
  • Standardize units at the collection level (configure collectd appropriately)
  • Document unit conventions in your metrics naming scheme
  • Use Grafana variables to maintain unit consistency across dashboards
  • Consider using metric suffixes like "_mb" in your metric names

When working with Grafana dashboards that pull memory metrics from Graphite (collected via collectd), you might encounter unexpected Y-axis units like "MiB" or "Bil" instead of the expected "MB". This happens because:

  • Grafana applies automatic unit scaling based on the raw metric values
  • Graphite and collectd may use different base units (bytes vs. bits)
  • The default unit configuration needs manual adjustment

Here's how to properly configure the Y-axis units in Grafana:

  1. Open your Grafana dashboard and edit the memory visualization panel
  2. Navigate to the "Axes" tab in panel settings
  3. Locate the "Unit" dropdown under Y-axis configuration
  4. Select "Data (SI)" → "bytes (SI)" for MB/GB display
  5. Alternatively, use "Data (IEC)" → "bytes (IEC)" for MiB/GiB

For Graphite data sources, you might need additional configuration:

// Example panel JSON with custom unit configuration
{
  "yaxes": [
    {
      "format": "bytes",
      "label": "Memory Usage",
      "logBase": 1,
      "max": null,
      "min": "0",
      "show": true,
      "units": ["MB", "GB"]
    }
  ]
}

For dynamic unit selection across dashboards:

// Dashboard variable definition
{
  "name": "memory_unit",
  "label": "Memory Unit",
  "type": "custom",
  "query": "MB,GB,GiB",
  "current": {
    "text": "MB",
    "value": "MB"
  }
}

// Panel reference to the variable
${memory_unit}

If units still don't display correctly:

  • Verify your collectd configuration uses consistent units:
    <Plugin memory>
      ValuesAbsolute true
      ValuesPercentage false
    </Plugin>
  • Check Graphite's storage-aggregation.conf for proper aggregation methods
  • Ensure there's no unit conversion happening in intermediate processing

For optimal memory metric displays:

  • Standardize on either SI (MB/GB) or IEC (MiB/GiB) units across your stack
  • Set explicit min/max values when appropriate
  • Consider using dual Y-axes for different memory metrics
  • Document your unit conventions in dashboard descriptions