{"id":38819994,"url":"https://github.com/jonwinton/ddqp","last_synced_at":"2026-01-17T13:03:29.289Z","repository":{"id":61625550,"uuid":"537515470","full_name":"jonwinton/ddqp","owner":"jonwinton","description":"A parser library for DataDog queries","archived":false,"fork":false,"pushed_at":"2026-01-16T04:57:39.000Z","size":465,"stargazers_count":11,"open_issues_count":5,"forks_count":9,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-16T20:01:40.051Z","etag":null,"topics":["datadog","go","golang","parser","query-parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonwinton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-09-16T15:28:20.000Z","updated_at":"2025-11-13T15:23:02.000Z","dependencies_parsed_at":"2023-01-29T16:45:50.636Z","dependency_job_id":"6753d066-c566-499f-b181-fbfc73e4f8fc","html_url":"https://github.com/jonwinton/ddqp","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jonwinton/ddqp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonwinton%2Fddqp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonwinton%2Fddqp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonwinton%2Fddqp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonwinton%2Fddqp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonwinton","download_url":"https://codeload.github.com/jonwinton/ddqp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonwinton%2Fddqp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28508943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T11:50:55.898Z","status":"ssl_error","status_checked_at":"2026-01-17T11:50:55.569Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datadog","go","golang","parser","query-parser"],"created_at":"2026-01-17T13:03:29.189Z","updated_at":"2026-01-17T13:03:29.275Z","avatar_url":"https://github.com/jonwinton.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DDQP (DataDog Query Parser)\n\nDDQP is a Go package for parsing and constructing DataDog queries programmatically. It provides a structured way to work with different types of DataDog queries without having to manually handle string manipulation or complex regex patterns.\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/jonwinton/ddqp.svg)](https://pkg.go.dev/github.com/jonwinton/ddqp)\n\n## Features\n\n- Parse DataDog queries into structured Go objects\n- Generate queries programmatically with type safety\n- Support for complex expressions, filters, and conditions\n- Handle various query types (metrics, monitors)\n\n## Installation\n\n```bash\ngo get github.com/jonwinton/ddqp\n```\n\n## Usage\n\n### Basic Metric Query Parsing\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"github.com/jonwinton/ddqp\"\n)\n\nfunc main() {\n    parser := ddqp.NewMetricQueryParser()\n    query, err := parser.Parse(\"sum:system.cpu.user{host:web-* AND env:prod} by {host}\")\n    if err != nil {\n        panic(err)\n    }\n\n    // Access structured data\n    fmt.Printf(\"Aggregator: %s\\n\", query.Query[0].Aggregator)\n    fmt.Printf(\"Metric Name: %s\\n\", query.Query[0].MetricName)\n\n    // Convert back to string\n    fmt.Printf(\"Query String: %s\\n\", query.String())\n}\n```\n\n### Monitor Query Parsing\n\n```go\nparser := ddqp.NewMetricMonitorParser()\nmonitor, err := parser.Parse(\"avg(last_5m):system.cpu.user{env:prod} \u003e 80\")\nif err != nil {\n    panic(err)\n}\n\nfmt.Printf(\"Aggregation: %s\\n\", monitor.Aggregation)\nfmt.Printf(\"Window: %s\\n\", monitor.EvaluationWindow)\nfmt.Printf(\"Threshold: %g\\n\", monitor.Threshold)\nfmt.Printf(\"Comparator: %s\\n\", monitor.Comparator)\n```\n\n### Complex Expressions\n\n```go\nparser := ddqp.NewMetricExpressionParser()\nexpression, err := parser.Parse(\"(sum:system.cpu.user{*} / sum:system.cpu.idle{*}) * 100\")\nif err != nil {\n    panic(err)\n}\n\n// Formulas can be used to better understand expressions\nformula := ddqp.NewMetricExpressionFormula(expression)\nfmt.Printf(\"Formula: %s\\n\", formula.Formula)\nfor k, v := range formula.Expressions {\n    fmt.Printf(\"%s = %s\\n\", k, v)\n}\n```\n\n## Architecture\n\nDDQP is built around [`participle`](https://github.com/alecthomas/participle), a parser library that makes it easy to define parsers from Go struct definitions. This allows DDQP to focus on capturing the variations present in the DataDog query language.\n\nThe parser is divided into separate components:\n\n- **MetricQuery**: Basic DataDog metric queries\n- **MetricFilter**: Filter expressions for queries (e.g., `{host:web-* AND env:prod}`)\n- **MetricMonitor**: Monitor queries with evaluation windows and thresholds\n- **MetricExpression**: Mathematical expressions involving metrics\n\n## Development\n\nThis project uses [Hermit](https://cashapp.github.io/hermit/) for managing dependencies and Go tools.\n\n```bash\n# Activate Hermit environment\nsource ./bin/activate-hermit\n\n# Run tests\n./scripts/test\n\n# Run linter\n./bin/golangci-lint run\n```\n\n### Conventional Commits\n\nThis project follows [Conventional Commits](https://www.conventionalcommits.org/) for commit messages and PR titles. This enables:\n\n- Automatic changelog generation\n- Semantic versioning based on commit types\n- Better collaboration and git history\n\n**PR titles are validated by CI** to ensure they follow the format.\n\nSee [COMMIT_CONVENTION.md](.github/COMMIT_CONVENTION.md) for detailed guidelines.\n\n**Quick reference:**\n\n```bash\nfeat: add new feature\nfix: bug fix\ndocs: documentation changes\ntest: add or update tests\nrefactor: code refactoring\nperf: performance improvements\nchore: maintenance tasks\n```\n\n### Releases\n\nReleases are fully automated using conventional commits:\n\n```bash\n# Auto-detect next version and create release\n./scripts/create-release.sh\n\n# Preview what the next version will be\nsvu next\n\n# Preview upcoming changelog\ngit-cliff --config cliff.toml --unreleased\n```\n\nThe release workflow will:\n\n1. Calculate version using [svu](https://github.com/caarlos0/svu)\n2. Generate changelog using [git-cliff](https://git-cliff.org/)\n3. Publish release notes automatically\n\nSee [RELEASE_SETUP.md](./RELEASE_SETUP.md) for detailed instructions.\n\n## Supported Features\n\n- **Metric queries** with filtering and grouping\n- **Monitor queries** with thresholds and comparisons\n- **Mathematical expressions** combining multiple metrics\n- **Complex filters** with AND/OR/NOT logic\n- **Comparison operators** (\u003e, \u003c, \u003e=, \u003c=)\n- **Regex filters** using `:~` operator\n\n## Examples\n\nSee the [`_examples`](./_examples/) directory for more usage examples:\n\n- [Basic Metrics](./examples/metrics/): Working with metric queries\n- [Filters](./examples/filters/): Advanced filter usage\n- [Monitors](./examples/monitors/): Creating and parsing monitors\n- [Expressions](./examples/expressions/): Complex mathematical expressions\n\n## License\n\nThis project is licensed under the terms found in the [LICENSE](./LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonwinton%2Fddqp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonwinton%2Fddqp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonwinton%2Fddqp/lists"}