-
Notifications
You must be signed in to change notification settings - Fork 263
4665: Setup for Log v2 config #2298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
matt-metivier
wants to merge
53
commits into
main
Choose a base branch
from
4665
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically. |
4565: Updating stack id docs 4565: fixing test 4565: running test and fixing comment 4565: owner update 4565: fixing path Fix concurrency race condition in generate tool Fix 'panic: send on closed channel' error in generateImportBlocks. The issue was a classic Go concurrency race condition: - Goroutines called wg.Done() before sending to results channel - Main goroutine could close(results) while sends were still pending - This caused 'send on closed channel' panics Fix: Move all 'results <- result{}' sends BEFORE wg.Done() calls to ensure all channel operations complete before waitgroup finishes. This prevents the channel from being closed while goroutines are still trying to send results. Fixes integration test failures in CI. Add dedicated environment check for Asserts service tests Create CheckAssertsTestsEnabled() function to properly gate Asserts tests. Tests now require TF_ACC_ASSERTS=true to run, preventing 404 errors when Asserts service is not available in test environments. This follows the same pattern as other optional cloud services and ensures tests only run when the service is actually configured. Fix linter error: remove unused getTestStackIDForDisabled function Removed duplicate getTestStackIDForDisabled function and unnecessary imports. Both test files now share the getTestStackID function from the same package. Fixes: - unused function (golangci-lint) - unnecessary imports (os, strconv, require) All tests still pass and linter is clean. 4565: adding test 4565: adding test 4565: adding to catalog Update asserts resources and configuration 4565: fixing client 4565: update to add stack_id 4565: small revert 4565: Setup for asserts TF
This reverts commit 3a580f2.
This reverts commit 29e889d.
This reverts commit dc08865.
4565: Updating stack id docs 4565: fixing test 4565: running test and fixing comment 4565: owner update 4565: fixing path Fix concurrency race condition in generate tool Fix 'panic: send on closed channel' error in generateImportBlocks. The issue was a classic Go concurrency race condition: - Goroutines called wg.Done() before sending to results channel - Main goroutine could close(results) while sends were still pending - This caused 'send on closed channel' panics Fix: Move all 'results <- result{}' sends BEFORE wg.Done() calls to ensure all channel operations complete before waitgroup finishes. This prevents the channel from being closed while goroutines are still trying to send results. Fixes integration test failures in CI. Add dedicated environment check for Asserts service tests Create CheckAssertsTestsEnabled() function to properly gate Asserts tests. Tests now require TF_ACC_ASSERTS=true to run, preventing 404 errors when Asserts service is not available in test environments. This follows the same pattern as other optional cloud services and ensures tests only run when the service is actually configured. Fix linter error: remove unused getTestStackIDForDisabled function Removed duplicate getTestStackIDForDisabled function and unnecessary imports. Both test files now share the getTestStackID function from the same package. Fixes: - unused function (golangci-lint) - unnecessary imports (os, strconv, require) All tests still pass and linter is clean. 4565: adding test 4565: adding test 4565: adding to catalog Update asserts resources and configuration 4565: fixing client 4565: update to add stack_id 4565: small revert 4565: Setup for asserts TF
# Conflicts: # internal/resources/asserts/resource_alert_config_test.go # internal/resources/asserts/resource_disabled_alert_config_test.go
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Overview
Extends Terraform provider support for managing Asserts configurations through Grafana Cloud by adding resources for Custom Model Rules and Log Drilldown Environment Config. This implementation uses the existing integration with the Grafana Asserts App Plugin, leveraging Grafana Service Account authentication and stack-scoped API calls.
🚀 Features Added
Resources Implemented
grafana_asserts_custom_model_rules
— Manages custom model rule configurations.grafana_asserts_log_drilldown_config
— Manages per-environment log drilldown configuration.Authentication & Architecture
X-Scope-OrgID
headersgrafana-asserts-public-clients/go/gcom
(repo)🏗️ Architecture
API Flow:
Plugin API Gateway Endpoints:
Key Implementation Details:
github.com/grafana/grafana-asserts-public-clients/go/gcom
(repo)TenantEnvConfigResponseDto
,EnvironmentDto
,LogConfigDto
Headers Used:
Authorization: Bearer {token}
X-Scope-OrgID: {stackID}
Content-Type: application/json
💻 Example Usage
Import for Log Drilldown Config:
terraform import grafana_asserts_log_drilldown_config.name "<environment_name>"
📁 Files Added/Modified
New Files
internal/resources/asserts/resource_log_drilldown_config.go
— Log Drilldown Environment Config resource (CRUD viaLogConfigControllerAPI
)internal/resources/asserts/resource_log_drilldown_config_test.go
— Acceptance tests (create/update/read/delete/import)examples/resources/grafana_asserts_log_drilldown_config/resource.tf
— Example usageexamples/resources/grafana_asserts_log_drilldown_config/import.sh
— Import helperdocs/resources/asserts_log_drilldown_config.md
— Generated documentationinternal/resources/asserts/resource_custom_model_rules.go
— Custom Model Rules resourceinternal/resources/asserts/resource_custom_model_rules_test.go
— Acceptance testsexamples/resources/grafana_asserts_custom_model_rules/resource.tf
— Example usagedocs/resources/asserts_custom_model_rules.md
— Generated documentationModified Files
internal/resources/asserts/resources.go
— Registered new resourceinternal/resources/asserts/catalog-resource.yaml
— Added Backstage catalog entriesgo.mod
/go.sum
— Bumpedgrafana-asserts-public-clients/go/gcom
to latest with updated DTOs and endpointsgo generate ./...
)Test Categories
Running Tests
🔧 Implementation Notes
Client Configuration
/api/plugins/grafana-asserts-app/resources/asserts/api-server
CustomModelRulesControllerAPI
: PUT model rulesLogConfigControllerAPI
: GET tenant env config, POST upsert env config, DELETE env config by nameEnvironmentDto
with nestedLogConfigDto
Plugin Integration
Resource Configuration
X-Scope-OrgID
name
name
terraform import grafana_asserts_log_drilldown_config.name "<environment_name>"
Error Handling
📚 Dependencies
github.com/grafana/grafana-asserts-public-clients/go/gcom
— Generated API client (repo)🔐 Security & Permissions
Uses Grafana Service Account authentication
Stack-scoped access via
X-Scope-OrgID
No additional Asserts-specific tokens required
Inherits Grafana’s security model
Added
grafana_asserts_log_drilldown_config
resource with env-scoped CRUD viaLogConfigControllerAPI
Updated client to latest; adopted updated DTOs (
EnvironmentDto
,LogConfigDto
,TenantEnvConfigResponseDto
)Preserved existing
grafana_asserts_custom_model_rules
; examples, docs, tests for both resourcesAdded example import script; updated docs and catalog entries