{"id":22066071,"url":"https://github.com/pcpratheesh/golang-influxdb-example","last_synced_at":"2025-03-23T18:22:21.112Z","repository":{"id":57662363,"uuid":"399356283","full_name":"pcpratheesh/golang-influxdb-example","owner":"pcpratheesh","description":"Sample code snippet for influxdb with golang and fiber","archived":false,"fork":false,"pushed_at":"2021-08-24T06:38:13.000Z","size":10,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T00:36:10.734Z","etag":null,"topics":["code","example","fiber","go","golang","influx","influxdb","influxdb-client","snippets","time-series","time-series-database"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pcpratheesh.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-24T06:16:29.000Z","updated_at":"2021-09-07T06:21:00.000Z","dependencies_parsed_at":"2022-09-12T22:00:42.435Z","dependency_job_id":null,"html_url":"https://github.com/pcpratheesh/golang-influxdb-example","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/pcpratheesh%2Fgolang-influxdb-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcpratheesh%2Fgolang-influxdb-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcpratheesh%2Fgolang-influxdb-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pcpratheesh%2Fgolang-influxdb-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pcpratheesh","download_url":"https://codeload.github.com/pcpratheesh/golang-influxdb-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245145696,"owners_count":20568180,"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":["code","example","fiber","go","golang","influx","influxdb","influxdb-client","snippets","time-series","time-series-database"],"created_at":"2024-11-30T19:25:35.682Z","updated_at":"2025-03-23T18:22:21.077Z","avatar_url":"https://github.com/pcpratheesh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# golang-influx-example\nThis is a sample respository to leanrn how we can perform influx db operations with an api endpoint.\n\nTo get all items from db\n```go\napp.Get(\"/get\", func(c *fiber.Ctx) error {\n    data, err := influxInstance.GetAllItems()\n    if err != nil {\n        return c.Status(fiber.ErrBadGateway.Code).JSON(err.Error())\n    }\n    return c.JSON(data)\n})\n```\n\nTo create new entry to the db\n\n```go\napp.Post(\"/create\", func(c *fiber.Ctx) error {\n    err := influxInstance.InsertSample()\n    if err != nil {\n        return c.Status(fiber.ErrBadGateway.Code).JSON(err.Error())\n    }\n    return c.JSON(\"successfully inserted\")\n})\n```\n\n## configuration\n- rename config.sample.yml into config.yml\n- change the configuration variables\n\n```yml\nserver:\n  host: server host\n  port: server running port\n\ninfluxInstance:\n  host: db host\n  port: db port\n  db: database\n  user: db user\n  password: db password\n```\n### Run\n```go\n    go run main.go\n```\n\n\n## References\n- InfluxDB : https://docs.influxdata.com/influxdb/v1.8/introduction/get-started/\n- InfluxDB Golang Client : https://github.com/influxdata/influxdb-client-go\n- Go Fiber : https://github.com/gofiber/fiber","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcpratheesh%2Fgolang-influxdb-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpcpratheesh%2Fgolang-influxdb-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpcpratheesh%2Fgolang-influxdb-example/lists"}