{"id":23478367,"url":"https://github.com/opennms/usage-stats-handler","last_synced_at":"2025-04-14T21:31:36.265Z","repository":{"id":47160448,"uuid":"54485909","full_name":"OpenNMS/usage-stats-handler","owner":"OpenNMS","description":"Backend for handling usage statistic reports from OpenNMS instances","archived":false,"fork":false,"pushed_at":"2024-12-16T20:15:17.000Z","size":658,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-12-16T21:25:12.163Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":false,"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/OpenNMS.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}},"created_at":"2016-03-22T15:20:32.000Z","updated_at":"2024-12-16T20:14:37.000Z","dependencies_parsed_at":"2024-05-15T15:04:24.929Z","dependency_job_id":"34cd8899-aa7d-4ffe-8d5e-9498520c1ced","html_url":"https://github.com/OpenNMS/usage-stats-handler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenNMS%2Fusage-stats-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenNMS%2Fusage-stats-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenNMS%2Fusage-stats-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenNMS%2Fusage-stats-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenNMS","download_url":"https://codeload.github.com/OpenNMS/usage-stats-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231143160,"owners_count":18334356,"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","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":[],"created_at":"2024-12-24T19:19:03.703Z","updated_at":"2024-12-24T19:19:06.754Z","avatar_url":"https://github.com/OpenNMS.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# usage-stats-handler\n\nA node/express web app for handling REST requests for OpenNMS usage statistics and user data.\n\n## How to test\n\n* Make sure that node.js is installed on the system\n* Currently should use npm version 10 or higher; node version 18 or higher\n* Change to the project folder and run the following command\n\n```shell\nnpm install\n```\n\n* Start elastic search docker container first (don't need this if you are only testing the `user-data-collection` feature)\n\n```shell\ndocker run -d -p 9200:9200 -p 9300:9300 -e \"discovery.type=single-node\" docker.elastic.co/elasticsearch/elasticsearch:7.6.2\n```\n\n* Run the following command to compile the code and start the server\n\n```shell\nnpm start\n```\n\n## Docker development\n\n* Run Usage Stats Handler, Elasticsearch and Grafana\n\n```shell\ndocker-compose up --build --abort-on-container-exit --remove-orphans --force-recreate\n```\n\n* Note: At times elasticsearch hangs on startup, to fix this either run it again and/or run\n\n```shell\ndocker system prune\n```\n\n## Testing with Elasticsearch\n\n* Running `test/opennms-test.http` in Intellij to test or using the curl to post report\n* Using the following command to verify the report saved\n\n```shell\ncurl -v -X POST --location \"http://localhost:9200/opennms_log/_count?pretty\"\ncurl -v -X POST --location \"http://localhost:9200/opennms_system/_count?pretty\"\n```\n* Visualise the grafana graph update with new values on a refresh \n\n## Running in the production environment\n\nAdd a file `config/production.json` which is a copy of `config/default.json` but with actual production values populated.\n\n* Note: make sure not to check in `config/production.json` as it may contain credentials.\n\nThen:\n\n```shell\nnpm run start:prod\n```\n\nIf you are running this in a different way (e.g. as part of a service), you can run `npm build-only` to build. Make sure to set the `NODE_ENV` environment variable to `production` (`export NODE_ENV=production`), and also set `NODE_CONFIG_DIR` to the `config` directory, then run the `dist/app.js` file:\n\n```shell\nexport NODE_ENV=production\nexport NODE_CONFIG_DIR=/opt/usage-stats-handler/config\nnode dist/app.js\n```\n\n## REST endpoints\n\n- `GET /` Base URL, but there's actually nothing at that path, it will return a 404\n- `GET /ping` Get a basic ping response\n- `POST /usage-report` Send an OpenNMS Horizon usage report\n- `POST /hs-usage-report` Send an OpenNMS Horizon Stream usage report\n- `POST /user-data-collection` Submit user data collection data\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopennms%2Fusage-stats-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopennms%2Fusage-stats-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopennms%2Fusage-stats-handler/lists"}