Skip to content

Commit

Permalink
[receiver/influxdbreceiver] Add the /ping endpoint for enhanced compa…
Browse files Browse the repository at this point in the history
…tibility (#29662)

**Description:** This PR supplements the receiver `influxdbreceiver`
with an implementation of the `/ping`
[endpoint](https://docs.influxdata.com/influxdb/v2/api/#operation/GetPing).
Various third-party applications use this to check the availability of
the receiver before sending metrics, e.g. checkmk.

**Link to tracking Issue:** #29594

**Testing:** Basic tests and end to end testing with the third party
application
[checkmk](https://docs.checkmk.com/latest/en/metrics_exporter.html).

**Documentation:** No additional documentation has been added.
- The user does not interact directly with this endpoint.
- There are no configuration options.
  • Loading branch information
jve-engineering committed Dec 11, 2023
1 parent 50794af commit 5b66f0e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .chloggen/influxdbreceiver-add_ping_endpoint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: receiver/influxdbreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Endpoint `/ping` added to enhance compatibility with third party products"

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [29594]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
5 changes: 5 additions & 0 deletions receiver/influxdbreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func (r *metricsReceiver) Start(_ context.Context, host component.Host) error {
router := http.NewServeMux()
router.HandleFunc("/write", r.handleWrite) // InfluxDB 1.x
router.HandleFunc("/api/v2/write", r.handleWrite) // InfluxDB 2.x
router.HandleFunc("/ping", r.handlePing)

r.wg.Add(1)
r.server, err = r.httpServerSettings.ToServer(host, r.settings, router)
Expand Down Expand Up @@ -201,3 +202,7 @@ func (r *metricsReceiver) handleWrite(w http.ResponseWriter, req *http.Request)

w.WriteHeader(http.StatusNoContent)
}

func (r *metricsReceiver) handlePing(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusNoContent)
}

0 comments on commit 5b66f0e

Please sign in to comment.