-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhello-http.py
More file actions
25 lines (21 loc) · 944 Bytes
/
hello-http.py
File metadata and controls
25 lines (21 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import datetime
"""
Entry point for HTTP request triggers that is called when requests hit custom endpoint.
Arguments: influxdb3_local (API), query_parameters, request_headers, request_body, args (optional).
Returns response object to the client.
"""
def process_request(influxdb3_local, query_parameters, request_headers, request_body, args=None):
# Log that the plugin was triggered
influxdb3_local.info("Hello from HTTP plugin!")
# Log request details
influxdb3_local.info(f"Query parameters: {query_parameters}")
# Write a record of the request
line = LineBuilder("api_requests")
line.tag("endpoint", "hello")
line.int64_field("received", 1)
influxdb3_local.write(line)
# Return a response with timezone-aware UTC timestamp
return {
"message": "Hello from InfluxDB 3 Processing Engine!",
"timestamp": datetime.datetime.now(datetime.timezone.utc).isoformat()
}