Grafana Cloud

Create usage groups for a customer without existing configuration

This section describes how to create usage groups for a customer stack that does not currently have any usage groups configured.

Before you begin

Note

Ensure you have completed the prerequisites.

Step 1: Select the customer context

Use gcx CLI to switch to the desired context:

Bash
gcx config use-context <CONTEXT>

For more details on how to correctly configure contexts, refer to the gcx CLI Configuration.

Step 2: Check whether usage groups have already been configured

Note

A namespace can contain only one MimirUsageGroupsConfiguration resource. Any attempt to create another in the same namespace fails.

To verify if usage groups are already configured in your stack, run:

Bash
  gcx resources get mimirusagegroupsconfigurations
  • If no output is returned, you can proceed to Step 3
  • If you see output similar to the following, usage groups have already been configured. To modify an existing configuration, refer to Update an existing configuration.
  KIND                            GROUP                   NAME
  MimirUsageGroupsConfiguration   mimir.ext.grafana.com   config

Step 3: Create the configuration file

Define a MimirUsageGroupsConfiguration resource in a YAML (or JSON) file named config.yaml.

For example:

YAML
apiVersion: mimir.ext.grafana.com/v1alpha1
kind: MimirUsageGroupsConfiguration
metadata:
  name: config
spec:
  usageGroups:
    grafanacloud_usage_group/errors: '{status=~"5.."}'
    grafanacloud_usage_group/production: '{env=~"prod.*"}'

Save this file locally, for example at:

  /path/to/usage-groups/config.yaml

Step 4: Push the configuration

Apply the configuration using the following command:

Bash
  gcx resources push --path ./path/to/usage-groups/config.yaml

If the configuration is valid and successfully applied, the following message is displayed:

  ✔ 1 resources pushed, 0 errors

This indicates that a MimirUsageGroupsConfiguration resource named config has been created in the namespace associated with the customer’s stack. For more details on how to manage resources using gcx CLI, refer to Manage resources with Grafana CLI.