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:
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
MimirUsageGroupsConfigurationresource. Any attempt to create another in the same namespace fails.
To verify if usage groups are already configured in your stack, run:
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 configStep 3: Create the configuration file
Define a MimirUsageGroupsConfiguration resource in a YAML (or JSON) file named config.yaml.
For example:
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.yamlStep 4: Push the configuration
Apply the configuration using the following command:
gcx resources push --path ./path/to/usage-groups/config.yamlIf the configuration is valid and successfully applied, the following message is displayed:
✔ 1 resources pushed, 0 errorsThis 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.
Was this page helpful?
Related resources from Grafana Labs


