{"id":30913032,"url":"https://github.com/rabobank/cf-metrics-exporter","last_synced_at":"2025-09-09T22:18:59.540Z","repository":{"id":312706808,"uuid":"990528967","full_name":"rabobank/cf-metrics-exporter","owner":"rabobank","description":"Export custom metrics from Java application to Cloud Foundry metrics endpoint","archived":false,"fork":false,"pushed_at":"2025-09-01T14:04:17.000Z","size":108,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-01T14:40:59.860Z","etag":null,"topics":["cloudfoundry","javaagent","jvm","metrics-exporter"],"latest_commit_sha":null,"homepage":"","language":"Java","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/rabobank.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2025-05-26T08:51:56.000Z","updated_at":"2025-09-01T14:00:38.000Z","dependencies_parsed_at":"2025-09-01T14:41:02.260Z","dependency_job_id":"6fef155d-e8a8-4b19-8cd0-e915423cfeba","html_url":"https://github.com/rabobank/cf-metrics-exporter","commit_stats":null,"previous_names":["rabobank/cf-metrics-exporter"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rabobank/cf-metrics-exporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabobank%2Fcf-metrics-exporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabobank%2Fcf-metrics-exporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabobank%2Fcf-metrics-exporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabobank%2Fcf-metrics-exporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rabobank","download_url":"https://codeload.github.com/rabobank/cf-metrics-exporter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rabobank%2Fcf-metrics-exporter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274370211,"owners_count":25272775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cloudfoundry","javaagent","jvm","metrics-exporter"],"created_at":"2025-09-09T22:18:57.204Z","updated_at":"2025-09-09T22:18:59.525Z","avatar_url":"https://github.com/rabobank.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cf-metrics-exporter\n\nA JVM agent to send custom metrics to the cloud foundry custom metrics endpoint.\n\nThis also counts the container-to-container traffic and can be used for autoscaling.\n\nThe purpose of this agent:\n* parse autoscaler endpoint info from VCAP_SERVICES\n* collect RPS (Requests Per Second) from the application\n* send RPS to cloud foundry custom metrics endpoint \n\nSends custom metric with name `custom_throughput` and unit: `rps`.\n(Cloud Foundry auto scaler has a `throughput` metric.)\n\nThe RPS is calculated as an average over the configured interval (default 10 seconds).\n\n### Spring Boot RPS\n\nTransform these classes with ByteBuddy on SpringBoot API to count request/reply:\n\n    * org.springframework.web.servlet.DispatcherServlet#handle\n    * org.springframework.web.reactive.DispatcherHandler#handle\n\nNo need to enable Tomcat MBeans via application settings\n\nWorks for all Spring Boot servers:\n* Netty (WebFlux/Reactor)\n* Tomcat (also with virtual threads)\n* Undertow\n\nUse `rspType=spring-request` to enable this feature (default).\n\n### Tomcat RPS\n\nFor Tomcat use the JMX MBean and Attribute:\n* `Tomcat:type=GlobalRequestProcessor,name=\"http-nio-8080\"` (or similar, depending on your Tomcat configuration)\n* `Attribute: requestCount`\n\nNeeds explicit application setting: `server.tomcat.mbeanregistry.enabled=true`\n\nUse `rspType=tomcat-mbean` to enable this feature.\n\n### Random RPS\n\nThis is a random RPS generator, useful for testing purposes. It generates a random number of requests per second.\n\nUse `rspType=random` to enable this feature.\n\n## Agent usage\n\nCopy the jar to the CF container and activate it via the `-javaagent` option.\n\nIn the `manifest.yml` file, add the following:\n\n    -javaagent:/path/to/cf-metrics-exporter-\u003cversion\u003e.jar\n\nwith settings:\n\n    -javaagent:/path/to/cf-metrics-exporter-\u003cversion\u003e.jar=debug,rpsType=random,intervalSeconds=5\n\n## Agent Settings\n\nThe following settings are available:\n- `debug`: Enable debug logging.\n- `rpsType`: Type of RPS to use. Options are `spring-request` (default), `random`, `tomcat-mbean`.\n- `intervalSeconds`: Interval in seconds for sending metrics. Default is 10 seconds. Note: the average RPS is calculated for every interval.\n- `metricsEndpoint`: The endpoint to send metrics to. Not used currently, will pick it up from VCAP_SERVICES.\n\nRun with debug enabled to see stacktraces of exceptions.\n\n## Env variables\n\nThe following environment variables are used from within the cloud foundry container:\n- VCAP_APPLICATION\n- VCAP_SERVICES\n- CF_INSTANCE_INDEX\n\nThe VCAP_SERVICES should contain the custom metrics endpoint and basic auth credentials. mTLS is not supported.\n\nThere is a `src/test/resources/test.env` file that can be used to set these variables for local testing.\nThe `src/test/resources/test-missing-basic-auth.env` can be used to test with mTLS instead of basic auth.\n\nUse via `source src/test/resources/test.env` in your terminal or add as env file in the IDE runner.\n\n## Build\n\nTo build the project, use the following command:\n\n```bash\n./mvnw clean package\n```\n\nThe agent jar will be created in the `target` directory: `target/cf-metrics-exporter-LOCAL-SNAPSHOT.jar`\n\n## Test metrics endpoint\n\nA Wiremock server is included to test the agent. It can be used with basic-auth (port 58080) and mTLS (port 58443).\n\nThe certificates for mTLS are generated with the `mtls-certs/mtls-certificate-setup.sh` script.\nThis script is executed in the compile step of the Maven build.\nThe certs are in `target/generated-certs`.\n\nBeware: the client private key is not exactly the same as the ones used in cloud foundry,\nso parse errors were present when reading the private key on cloud foundry. The bouncy castles\nlibrary is currently included for the correct parsing of the client private key. This was \nthe error without bouncy castles:\n\n```\nFailed to load private client key Caused by: java.security.spec.InvalidKeySpecException: java.security.InvalidKeyException: IOException : algid parse error, not a sequence Caused by: java.security.InvalidKeyException: IOException : algid parse error, not a sequence\n```\n\n\n# Notes\n\nThis is a \"Beta\" release, feedback is welcome!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frabobank%2Fcf-metrics-exporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frabobank%2Fcf-metrics-exporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frabobank%2Fcf-metrics-exporter/lists"}