-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test httpjson log handler #127
Comments
i tested this with a local http server that handles json data: from http.server import BaseHTTPRequestHandler, HTTPServer
import json
class JSONRequestHandler(BaseHTTPRequestHandler):
def _set_response(self, status_code=200):
self.send_response(status_code)
self.send_header('Content-type', 'application/json')
self.end_headers()
def do_POST(self):
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length)
try:
# Parse JSON data
json_data = json.loads(post_data.decode('utf-8'))
print("Received JSON data:", json_data)
# Here you can handle the JSON data as needed
# Send a response back
self._set_response(200)
# send the data back to the client, just to show that we can do this
response_data = {'message': 'JSON data received successfully', 'data': json_data}
self.wfile.write(json.dumps(response_data).encode('utf-8'))
except json.JSONDecodeError as e:
self._set_response(400)
self.wfile.write(json.dumps({'error': 'Invalid JSON data'}).encode('utf-8'))
def run(server_class=HTTPServer, handler_class=JSONRequestHandler, port=8000):
server_address = ('', port)
httpd = server_class(server_address, handler_class)
print(f"Starting server on port {port}...")
httpd.serve_forever()
if __name__ == '__main__':
run() i also added the following to the {
'type': 'httpjson',
'url': 'http://127.0.0.1:8000/rfm',
'level': 'info',
# 'extra_headers': {'Authorization': 'Token YOUR_API_TOKEN'},
'extras': {
'facility': 'reframe',
'data-version': '1.0'
},
'ignore_keys': ['check_perfvalues']
}, seems to work nicely, this is the output of the server:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can be useful for visualization on a remote host
see https://reframe-hpc.readthedocs.io/en/stable/config_reference.html#the-httpjson-log-handler
The text was updated successfully, but these errors were encountered: