Skip to content

Creating Prometheus rule group namespace results in ValidationException in API but not Console

0

I am experiencing a ValidationException when attempting to create a Prometheus rule group namespace with the API but not the console.

If I run the following CLI request:

aws amp create-rule-groups-namespace --workspace-id 'my-workspace-id' --data 'base64 encoded data here' --name 'test'

Or this Terraform resource:

resource "aws_prometheus_rule_group_namespace" "test" {
  workspace_id = "my-workspace-id"
  name         = "test"
  data         = "base64 encoded data here"
}

I get the following error: An error occurred (ValidationException) when calling the CreateRuleGroupsNamespace operation: Malformed rule group namespace.

However if I use the exact same parameters in the console the namespace is created as expected.

I can recreate the problem with any value for "name"

1 Answer
0

The ValidationException you're encountering is likely related to the format of your rule groups data rather than the name parameter. When creating a rule groups namespace in Amazon Managed Service for Prometheus, the data parameter must contain a properly formatted, base64-encoded rules file.

The console may be handling the validation or formatting of your rules data differently than when you submit it directly via the API or Terraform. When using the console, there might be additional processing or validation that helps format your input correctly before submission.

For the API and Terraform approaches, ensure that:

  1. Your rules file follows the proper Prometheus rules format
  2. The rules file is correctly base64-encoded
  3. The encoded content doesn't contain any formatting issues

The "Malformed rule group namespace" error specifically points to an issue with the structure or content of your rules data, not with the workspace ID or name parameters.

To troubleshoot, you could:

  • Verify the format of your rules file before encoding
  • Double-check your base64 encoding process
  • Try to extract the exact data format that works in the console and use that in your API calls
  • Start with a minimal, valid rules file to test the API functionality

Remember that a rule groups namespace is associated with exactly one rules file, and the data must conform to the expected structure for Prometheus rules.
Sources
CreateRuleGroupsNamespace - Amazon Managed Service for Prometheus
create-rule-groups-namespace — AWS CLI 2.27.41 Command Reference
CreateWorkspace - Amazon Managed Service for Prometheus

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.