diff --git a/CHANGELOG.md b/CHANGELOG.md index c6212c7159..c0c279c3b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ 1. [16656](https://github.com/influxdata/influxdb/pull/16656): Check engine closed before collecting index metrics 1. [16412](https://github.com/influxdata/influxdb/pull/16412): Reject writes which use any of the reserved tag keys +### Bug Fixes + +1. [16527](https://github.com/influxdata/influxdb/pull/16527): fix /telegrafs panics when using org=org_name parameter + ### UI Improvements 1. [16575](https://github.com/influxdata/influxdb/pull/16575): Swap billingURL with checkoutURL diff --git a/http/telegraf.go b/http/telegraf.go index 2d26b795a6..52deb4d981 100644 --- a/http/telegraf.go +++ b/http/telegraf.go @@ -295,7 +295,7 @@ func decodeTelegrafConfigFilter(ctx context.Context, r *http.Request) (*platform } f.OrgID = orgID } else if orgNameStr := q.Get("org"); orgNameStr != "" { - *f.Organization = orgNameStr + f.Organization = &orgNameStr } return f, err } diff --git a/http/telegraf_test.go b/http/telegraf_test.go index eb8bce4815..cff0ab0608 100644 --- a/http/telegraf_test.go +++ b/http/telegraf_test.go @@ -82,6 +82,48 @@ func TestTelegrafHandler_handleGetTelegrafs(t *testing.T) { }`, }, }, + { + name: "get telegraf configs by organization name", + r: httptest.NewRequest("GET", "http://any.url/api/v2/telegrafs?org=tc1", nil), + svc: &mock.TelegrafConfigStore{ + FindTelegrafConfigsF: func(ctx context.Context, filter platform.TelegrafConfigFilter, opt ...platform.FindOptions) ([]*platform.TelegrafConfig, int, error) { + if filter.Organization != nil && *filter.Organization == "tc1" { + return []*platform.TelegrafConfig{ + { + ID: platform.ID(1), + OrgID: platform.ID(2), + Name: "tc1", + Description: "", + Config: "[[inputs.cpu]]\n", + }, + }, 1, nil + } + + return []*platform.TelegrafConfig{}, 0, fmt.Errorf("not found") + }, + }, + wants: wants{ + statusCode: http.StatusOK, + contentType: "application/json; charset=utf-8", + body: `{ + "configurations": [ + { + "id": "0000000000000001", + "orgID": "0000000000000002", + "name": "tc1", + "config": "[[inputs.cpu]]\n", + "labels": [], + "links": { + "self": "/api/v2/telegrafs/0000000000000001", + "labels": "/api/v2/telegrafs/0000000000000001/labels", + "members": "/api/v2/telegrafs/0000000000000001/members", + "owners": "/api/v2/telegrafs/0000000000000001/owners" + } + } + ] + }`, + }, + }, { name: "return CPU plugin for telegraf", r: httptest.NewRequest("GET", "http://any.url/api/v2/telegrafs", nil),