{"id":18941450,"url":"https://github.com/mchmarny/eventmaker","last_synced_at":"2025-07-01T09:05:51.808Z","repository":{"id":57710016,"uuid":"156468179","full_name":"mchmarny/eventmaker","owner":"mchmarny","description":"Utility to mock events with configurable format, random metric range, and frequency","archived":false,"fork":false,"pushed_at":"2023-03-29T21:33:21.000Z","size":5678,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T22:44:30.310Z","etag":null,"topics":["azure","client","events","golang","iot","iothub","message-bus","mqtt"],"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/mchmarny.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":"2018-11-07T00:38:35.000Z","updated_at":"2021-04-04T23:50:14.000Z","dependencies_parsed_at":"2024-06-20T02:40:21.635Z","dependency_job_id":"0d8d89ca-d9d7-496b-9523-b07d15df3b37","html_url":"https://github.com/mchmarny/eventmaker","commit_stats":null,"previous_names":["mchmarny/iot-event-maker","mchmarny/iot-code-client"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/mchmarny/eventmaker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Feventmaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Feventmaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Feventmaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Feventmaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mchmarny","download_url":"https://codeload.github.com/mchmarny/eventmaker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mchmarny%2Feventmaker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262933262,"owners_count":23386778,"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":["azure","client","events","golang","iot","iothub","message-bus","mqtt"],"created_at":"2024-11-08T12:28:06.354Z","updated_at":"2025-07-01T09:05:51.780Z","avatar_url":"https://github.com/mchmarny.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eventmaker\n\nUtility to mock events with configurable format, random metric range, and frequency. The supported event publishers are \n\n* [x] `stdout` - prints events to the console \n* [x] `http` - posts events to specified URL ([how-to](doc/HTTP.md))\n* [x] `iothub` - sends events to Azure IoT Hub ([how-to](doc/Azure-IoT-Hub.md))\n* [x] `eventhub` - sends events to Azure Event Hub ([how-to](doc/Azure-Event-Hub.md))\n* [ ] `iotcore` - sends events to GCP IoT Core \n* [x] `pubsub` - sends events to GCP Pub/Sub ([how-to](doc/GCP-PubSub.md))\n* [ ] `sns` - sends events to AWS SNS\n* [ ] `sqs` - sends events to AWS SQS\n\n\n[![Test](https://github.com/mchmarny/eventmaker/workflows/Test/badge.svg)](https://github.com/mchmarny/eventmaker/actions?query=workflow%3ATest) [![Release](https://github.com/mchmarny/eventmaker/workflows/Release/badge.svg)](https://github.com/mchmarny/eventmaker/actions?query=workflow%3ARelease) [![Go Report Card](https://goreportcard.com/badge/github.com/mchmarny/eventmaker)](https://goreportcard.com/report/github.com/mchmarny/eventmaker) ![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/mchmarny/eventmaker)\n\n## usage \n\nTo run `eventmaker` and publish events to the console run\n\n```shell\n./eventmaker stdout --file conf/thermostat.yaml\n```\n\nThe file parameter can be local file path or a remote URL (e.g. [thermostat.yaml](https://raw.githubusercontent.com/mchmarny/eventmaker/master/conf/thermostat.yaml)). For more information about all the flags and commands supported by the `eventmaker` use the `--help` or `-h` flag \n\n```shell \n./eventmaker -h\n```\n\nFor instructions how to publish events to other targets see the how-to links above\n\n## events \n\nThe mocked event look like this\n\n```json\n{\n    \"id\": \"fdf612b9-34a5-445e-9941-59c404ea9bef\",\n    \"src_id\": \"device-1\",\n    \"time\": 1589745397,\n    \"label\": \"temp\",\n    \"data\": 70.79129651786347,\n    \"unit\": \"celsius\"\n}\n```\n\n* `id` - is a globally unique ID generated for each event \n* `src_id` - is the device ID or name (configured using the `--device` flag at launch)\n* `time` - is the epoch (aka Unix time) of when the event was generated \n\nThe `label`, `data`, and `unit` elements are based on the metrics defined in the template (see [metrics](#metrics) section below)\n\n## metrics \n\n`eventmaker` dynamically configures metrics based on template where you can \n\nTo create events, define one or more metrics in a template file where you configure the frequency in which that metric should be generated along with its type and range of value. For example, configuration for a virtual thermostat with temperature and humidity metrics would look like this\n\n```yaml\n--- \nmetrics: \n- label: temperature\n  frequency: \"1s\"\n  unit: celsius\n  template: \n    type: float\n    min: 86.1\n    max: 107.5\n- label: humidity\n  frequency: \"1s\"\n  unit: percent\n  template: \n    type: int\n    min: 0\n    max: 100\n```\n\n That file where you define these metrics cab be either local (e.g. `--file conf/example.yaml`) or loaded from a remote URL (e.g. `--file https://raw.githubusercontent.com/mchmarny/eventmaker/master/conf/thermostat.yaml`)\n\n## example \n\nTo use `eventmaker` as a library, start by importing the package \n\n```shell\ngo get -u github.com/mchmarny/eventmaker\n```\n\nThen create some metric templates \n\n```go\nmetrics := []event.MetricTemplate{\n  {\n    Label:     \"temperature\",\n    Unit:      \"celsius\",\n    Frequency: time.Duration(1 * time.Second),\n    Template: event.ValueTemplate{\n      Type: \"float\",\n      Min:  39.1,\n      Max:  73.5,\n    },\n  },\n  {\n    Label:     \"humidity\",\n    Unit:      \"percent\",\n    Frequency: time.Duration(1 * time.Minute),\n    Template: event.ValueTemplate{\n      Type: \"int\",\n      Min:  0,\n      Max:  100,\n    },\n  },\n}\n```\n\nCreate a publisher target using one of the event senders (`stdout`, `iothub`, `http`)\n\n```go\ntarget, err := stdout.NewEventSender(ctx)\nif err != nil {\n  panic(err)\n}\n```\n\nAnd finally create an instance of `mocker` with the previously created `metrics` and `target` and start it\n\n```go\nmocker, err := mock.New(\"demo-device-1\", metrics, target)\nif err != nil {\n  panic(err)\n}\n\nmocker.Start(ctx)\n```\n\nA complete working example is available [here](example/main.go)\n\n## Disclaimer\n\nThis is my personal project and it does not represent my employer. I take no responsibility for issues caused by this code. I do my best to ensure that everything works, but if something goes wrong, my apologies is all you will get.\n\n## License\nThis software is released under the [Apache v2 License](./LICENSE)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmchmarny%2Feventmaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmchmarny%2Feventmaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmchmarny%2Feventmaker/lists"}