{"id":20801912,"url":"https://github.com/philips-software/variant","last_synced_at":"2026-01-14T21:52:19.843Z","repository":{"id":36951050,"uuid":"380165925","full_name":"philips-software/variant","owner":"philips-software","description":"Helps Thanos reach scraping targets on CF and beyond","archived":true,"fork":false,"pushed_at":"2025-03-11T11:57:36.000Z","size":538,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-18T12:11:30.156Z","etag":null,"topics":["autoscaler","cloudfoundry","prometheus","variant"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philips-software.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2021-06-25T07:55:21.000Z","updated_at":"2025-03-11T12:00:19.000Z","dependencies_parsed_at":"2024-03-05T15:39:39.469Z","dependency_job_id":"c0f033f0-e92c-4ec6-8552-fe2ed8a816e7","html_url":"https://github.com/philips-software/variant","commit_stats":{"total_commits":191,"total_committers":4,"mean_commits":47.75,"dds":0.2670157068062827,"last_synced_commit":"da1e641c81d8f8e196330efebcbd8143cd0c5e38"},"previous_names":["philips-labs/variant"],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/philips-software/variant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fvariant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fvariant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fvariant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fvariant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philips-software","download_url":"https://codeload.github.com/philips-software/variant/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philips-software%2Fvariant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28436231,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T21:32:52.117Z","status":"ssl_error","status_checked_at":"2026-01-14T21:32:33.442Z","response_time":107,"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":["autoscaler","cloudfoundry","prometheus","variant"],"created_at":"2024-11-17T18:26:09.543Z","updated_at":"2026-01-14T21:52:19.825Z","avatar_url":"https://github.com/philips-software.png","language":"Go","readme":"# DEPRECATED: please use https://github.com/dip-software/variant\n\n# Variant\n\nA sidecar for [Prometheus / Thanos](https://github.com/philips-labs/terraform-cloudfoundry-thanos) to discover scrape endpoints and rules.\nIt also manages the required CF network policies to support scraping via `apps.internal` routes. Finally, it can autoscale your CF applications based on arbitrary PromQL statements!\n\n## Disclaimer\n\nThis project is not endorsed or supported by HSDP. Use at your own risk.\n\n## Internals\nVariant uses the Cloud foundry API to:\n- Discover metrics endpoints and scrape targets through CF labels / annotations\n- Discover rules (alerts, recorders) through CF labels / annotations\n- Creates `rule_files_*.yml` containing discovered rules\n- Renders `scrape_configs:` and `rule_files:` sections\n- Adds / removes required CF network policies which enable Promethues to scrape target containers\n- Writes the `prometheus.yml` config file and triggers Prometheus to reload\n- Evaluates autoscaling rules and scales up/down your app accordingly\n\n  ![variant](resources/variant.svg)\n\n## Setting Labels and Annotations\n\nThe [Cloud foundry provider](https://registry.terraform.io/providers/philips-labs/cloudfoundry/latest/docs/resources/app#labels) supports managing\n`annotations` and `labels` and we recommend taking this approach. Alternatively, you can use the CF CLI.\n\n### Terraform example\n\n```hcl\nresource \"cloudfoundry_app\" \"kong\" {\n  // Stuff here\n  labels = {\n    \"variant.tva/exporter\"   = true\n    \"variant.tva/rules\"      = true\n    \"variant.tva/autoscaler\" = true\n  }\n  annotations = {\n    \"prometheus.exporter.port\" = \"8001\"\n    \"prometheus.exporter.path\" = \"/metrics\"\n    \"prometheus.exporter.scrape_interval\" = \"30s\"\n    \"prometheus.rules.json\" = jsonencode([\n      {\n        alert = \"KongWaitingConnections\"\n        expr = \"kong_nginx_http_current_connections{state=\\\"waiting\\\"} \u003e 2\"\n        for = \"1m\"\n        labels = {\n          severity = \"critical\"\n        }\n        annotations = {\n          summary = \"Instance {{ $labels.instance }} has more than 2 waiting connections per minute\"\n          description = \"{{ $labels.instance }} waiting http connections is at {{ $value }}\"\n        }\n      }\n    ])\n    \"prometheus.exporter.relabel_configs\" = jsonencode([\n      {\n        source_labels = [\"__name__\"]\n        regex = \"^(go|process).*$\"\n        action = \"drop\"\n      }\n    ])\n    \"variant.autoscaler.json\" = jsonencode([\n      {\n        min = 2\n        max = 5\n        expr = \"query_result \u003e 80\"\n        query = \"avg(avg_over_time(cpu{guid=\\\"{{ guid }}\\\"}[{{ window }}]))\"\n      }\n    ])\n  }\n}\n```\n\n### CF CLI example\n\n```shell\ncf set-label app tempo variant.tva/exporter=true\n```\n\n```shell\ncf curl v3/apps/GUID \\\n  -X PATCH \\\n  -d '{\n    \"metadata\": {\n      \"annotations\": {\n        \"prometheus.exporter.port\": \"8001\"\n      }\n    }\n  }'\n```\n\n## Labels\n\nLabels control which CF apps `variant` will examine for exporters or rules\n\n| Label                         | Description                                                         |\n|-------------------------------|---------------------------------------------------------------------|\n| `variant.tva/exporter=true`   | Variant will examine this app for Metrics exporter endpoints        |\n| `variant.tva/rules=true`      | Variant will look for Prometheus rules in the annotations           |\n| `variant.tva/tenant=default`  | Optionally associate the app to a tenant bucket                     |\n | `variant.tva/autoscaler=true` | Variant will look for Autoscaling configurations in the annotations | \n\n## Annotations\n\nAnnotations contain the configurations for metrics and rule definitions\n\n### For exporters\n\n| Annotation                             | Description                          | Default    |\n|----------------------------------------|--------------------------------------|------------|\n| `prometheus.exporter.port`             | The metrics ports to use             | `9090`     |\n| `prometheus.exporter.path`             | The metrics path to use              | `/metrics` |\n| `prometheus.exporter.scrape_interval`  | The scrape interval for this app     |            |\n| `prometheus.exporter.instance_name`    | The instance name to use (optional)  |            |\n | `prometheues.exporter.relabel_configs` | Relabel configs for this application |            |\n| `promethues.targets.port`              | The targets port to use (optional)   |            |\n| `prometheus.targets.path`              | The targets path to use (optional)   | `/targets` |\n\n### For rules\n\n| Annotation                | Description                    | Default           |\n|---------------------------|--------------------------------|-------------------|\n| `prometheus.rules.json`   | JSON string of `[]Rule`        | `jsonecode('[]')` |\n| `prometheus.rules.*.json` | JSON string of a `Rule` object |                   |\n\nWhen both formats are used the rules are merged in the final rule file rendering. This\nis useful to circumvent the `5000` character limit for annotation values in CF.\n\n### For autoscaler\n\n| Annotation                | Description               | Default            |\n|---------------------------|---------------------------|--------------------|\n| `variant.autoscaler.json` | JSON string of `[]Scaler` | `jsonencode('[]')` |\n\nThe `Scaler` object has the following attributes \n\n| Attribute | Description                                                                                                             | Default |\n|-----------|-------------------------------------------------------------------------------------------------------------------------|---------|\n | `min`     | Minimum instances to scale to                                                                                           |         |\n | `max`     | Maximum instances to scale to                                                                                           |         |\n | `query`   | The PromQL query to execute                                                                                             |         |\n | `expr`    | The expression to evaluate. Query result is `query_result`. If the expression evaluates to `true` the app will scale up |\n | `window`  | The window to use for queries                                                                                           | `1m`    |\n\nThe following placeholders may be used in the query definition\n\n| Placeholder    | Description                                         |\n|----------------|-----------------------------------------------------|\n | `{{ guid }}`   | The application GUID. Useful as label in your query |\n | `{{ window }}` | The window as defined in the Scaler object          |\n\n\n\n## Limiting scraping scope\n\nIn some deployments you may want to limit which apps variant will consider. There are several\nways of achieving this:\n\n- By limiting the CF functional accounts visibility i.e. only add to specific spaces\n- By configuring a tenant list and setting `variant.tva/tenant` label accordingly\n- By specifying a list of space GUIDs to filter on\n\n### CF functional account visibility\n\nVariant uses the CF API to look for candidate apps to scrap. By simply limiting which spaces your\nCF functional account can access you can control which apps are found\n\n### Tenant based filtering\n\nYou can label apps with `variant.tva/tenant` label and pass the values to variant through the `--tenants` parameter (comma separated). This\nwill tell variant to only consider apps label with these tenant values\n\n### CF spaces based filtering\n\nFinally, variant can take a list of CF space GUIDs through the `--spaces` parameter (comma separated). Variant will then only consider apps in these spaces, irrespective of the tenant configuration. This method is useful if you have an all-seeing CF functional account but still want to\nlimit which apps are considered by variant.\n\n## License\n\nLicense is MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilips-software%2Fvariant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilips-software%2Fvariant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilips-software%2Fvariant/lists"}