adx-mon
Copilot instructions29 starsChanged 14 months agoMITView on GitHub
Main binaries follow the pattern: CLI parsing → service creation → graceful shutdown handling.
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
21 rules. About 0 are common, 9 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 14
All services implement the pkg/service.Component interface:
- Very specific: line 25
Critical: After modifying ./api/v1/*.go, run make generate-crd CMD=update to regenerate manifests
- Very specific: line 28
Do NOT manually edit CRD YAML files: - always regenerate via make generate-crd CMD=update
- Distinctive: line 34
Configuration: All components use CLI flags with Kubernetes service account fallbacks
- Distinctive: line 37
Purpose: Write-Ahead Log segments provide durability and prevent data loss during outages
- Very specific: line 50
Run all tests: go test ./...
- Distinctive: line 53
Test environment needs Azure credentials for Kusto integration tests
- Very specific: line 56
All components: make build (creates bin/ directory)
- Very specific: line 62
After changing ./build/k8s/, run make k8s-bundle to regenerate deployment bundle
- Very specific: line 69
Follow standard Go project layout with cmd/, pkg/, api/ directories
- Very specific: line 70
Use structured logging via pkg/logger
- Very specific: line 77
Check errors immediately after function calls - don't ignore with _
- Distinctive: line 80
Always ensure goroutines can exit (via context cancellation or channels)
- Very specific: line 81
Use context.WithCancel pattern seen throughout main binaries
- Distinctive: line 86
Keep functions focused and single-purpose - break apart complex functions rather than adding branching logic
- Distinctive: line 87
Avoid "sideways pyramids" of nested conditionals - extract helper functions instead
- Distinctive: line 88
When adding new functionality, consider if it belongs in a separate function rather than expanding existing ones
- Distinctive: line 89
Prefer multiple small, testable functions over large functions with many responsibilities
- Distinctive: line 97
When modifying these areas, maintain existing pool patterns and avoid introducing new allocations
- Very specific: line 100
Use t.Helper() for test utility functions
- Very specific: line 101
Use require for tests (used in 94% of test files) - prefer over assert for cleaner failure handling
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
ADX-Mon AI Coding Instructions
Architecture Overview
ADX-Mon is a Kubernetes-native observability platform with 5 core components that form a unified data pipeline:
- Collector: Scrapes metrics (Prometheus-compatible) and forwards to Ingestors
- Ingestor: Receives metrics/logs via remote write, stores in WAL segments, uploads to Azure Data Explorer (ADX)
- Alerter: Executes KQL queries against ADX based on AlertRule CRDs, sends notifications
- Operator: Manages lifecycle of all components via Kubernetes CRDs
- ADX Exporter: Exports data from ADX for external systems
Core Patterns
Service Architecture
All services implement the pkg/service.Component interface:
type Component interface {
Open(ctx context.Context) error
Close() error
}Main binaries follow the pattern: CLI parsing → service creation → graceful shutdown handling.
CRD Workflow
- API types in
./api/v1/define Kubernetes resources (AlertRule, Ingestor, Collector, etc.) - Critical: After modifying
./api/v1/*.go, runmake generate-crd CMD=updateto regenerate manifests - CRD definitions live in both
./kustomize/bases/and./operator/manifests/crds/ - The
tools/crdgen/Docker-based system handles cross-platform CRD generation - Do NOT manually edit CRD YAML files - always regenerate via
make generate-crd CMD=update - The generated files use naming convention
*_crd.yaml(e.g.,functions_crd.yaml)
Data Flow Patterns
- Metrics: Collector → Ingestor → ADX (via WAL segments for reliability)
- Alerts: Alerter watches AlertRule CRDs → executes KQL queries → sends notifications
- Configuration: All components use CLI flags with Kubernetes service account fallbacks
WAL Segments (Critical for Reliability)
- Purpose: Write-Ahead Log segments provide durability and prevent data loss during outages
- Location: Stored locally on disk (
--storage-dir) before upload to ADX - Lifecycle: Ingestor creates segments → ages them → uploads to ADX → peer transfers for redundancy
- Key Parameters:
--max-segment-size,--max-segment-age,--max-transfer-agecontrol behavior - Backpressure: System signals backpressure when
--max-segment-countor--max-disk-usageexceeded - Implementation: See
pkg/wal/for core WAL logic andingestor/storage/for segment management
Database Naming Convention
Kusto endpoints use format: <database>=<endpoint> (case-sensitive database matching required)
Development Workflows
Testing
- Run all tests:
go test ./... - Integration tests:
make test(includes integration tests withINTEGRATION=1). These take longer to run. You should only run these when asked. - Individual packages:
go test ./pkg/logger - Test environment needs Azure credentials for Kusto integration tests
Build System
- All components:
make build(createsbin/directory) - Individual:
make build-alerter,make build-ingestor, etc. - Docker images:
make image(usesbuild/images/Dockerfile.*) - Note: Collector requires
CGO_ENABLED=1, others useCGO_ENABLED=0
K8s Bundle Management
- After changing
./build/k8s/, runmake k8s-bundleto regenerate deployment bundle - The
build/scripts/generate-bundle.shcreates deterministic bundles via Docker
Code Conventions
Go Standards
- Format all code with
go fmt(excluding vendor/) - Follow standard Go project layout with
cmd/,pkg/,api/directories - Use structured logging via
pkg/logger
Error Handling
- Services use context cancellation for graceful shutdown
- Background processes should respect context.Done() signals
- WAL segments provide durability during network/ADX outages
- Wrap errors with context using
fmt.Errorfwith%wverb for error chains - Check errors immediately after function calls - don't ignore with
_
Concurrency Patterns
- Always ensure goroutines can exit (via context cancellation or channels)
- Use
context.WithCancelpattern seen throughout main binaries - Background services should respect
ctx.Done()for graceful shutdown - Components follow Open/Close lifecycle with proper cleanup
Code Organization
- Keep functions focused and single-purpose - break apart complex functions rather than adding branching logic
- Avoid "sideways pyramids" of nested conditionals - extract helper functions instead
- When adding new functionality, consider if it belongs in a separate function rather than expanding existing ones
- Prefer multiple small, testable functions over large functions with many responsibilities
- Extract complex conditional logic into well-named boolean functions for readability
Performance-Critical Hot Paths
- Metrics ingestion:
collector/metrics/handler.gousespool.BytesBufferPoolfor zero-allocation buffer reuse - WAL segment operations:
pkg/wal/segment writes are benchmarked and performance-critical - Protobuf marshaling:
pkg/prompb/marshal/unmarshal operations are in the hot path - Storage writes:
storage/store.gouses object pools to avoid allocations during writes - When modifying these areas, maintain existing pool patterns and avoid introducing new allocations
Testing
- Use
t.Helper()for test utility functions - Use
requirefor tests (used in 94% of test files) - prefer overassertfor cleaner failure handling - Integration tests require
INTEGRATION=1environment variable - Azure credentials needed for Kusto integration tests
Kusto Integration
- Connection strings use Azure DefaultCredential for production
- Database names are case-sensitive and must match AlertRule specs
- KQL queries support templating with cluster labels (prefixed with
_)
Key Files to Understand
api/v1/groupversion_info.go: CRD group definition (adx-mon.azure.com/v1)pkg/service/service.go: Core service interfacepkg/wal/: WAL segment implementation for data durabilitytransform/transformer.go: Metrics filtering/transformation pipelineMakefile: Complete build and generation workflowsbuild/scripts/generate-bundle.sh: K8s deployment bundling logic
Documentation Structure
docs/: User-facing documentation (architecture, concepts, guides)docs/designs/: Technical design documents for major featuresREADME.md: Project overview and quick start for testing AlertRules
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

