examples: add Go logging webhook
This commit is contained in:
parent
5dc8286942
commit
d48b4e5dbd
2
Procfile
2
Procfile
|
@ -1,5 +1,5 @@
|
|||
a1: ./alertmanager -log.level=debug -storage.path=$TMPDIR/a1 -web.listen-address=:9093 -mesh.hardware-address=00:00:00:00:00:01 -mesh.nickname=a -mesh.listen-address=:8001 -config.file=examples/ha/alertmanager.yaml
|
||||
a2: ./alertmanager -log.level=debug -storage.path=$TMPDIR/a2 -web.listen-address=:9094 -mesh.hardware-address=00:00:00:00:00:02 -mesh.nickname=b -mesh.listen-address=:8002 -mesh.peer=127.0.0.1:8001 -config.file=examples/ha/alertmanager.yaml
|
||||
a3: ./alertmanager -log.level=debug -storage.path=$TMPDIR/a3 -web.listen-address=:9095 -mesh.hardware-address=00:00:00:00:00:03 -mesh.nickname=c -mesh.listen-address=:8003 -mesh.peer=127.0.0.1:8001 -config.file=examples/ha/alertmanager.yaml
|
||||
wh: ./examples/ha/webhook.py
|
||||
wh: go run ./examples/webhook/echo.go
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
|
||||
# Written by Nathan Hamiel (2010)
|
||||
|
||||
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
|
||||
from optparse import OptionParser
|
||||
|
||||
class RequestHandler(BaseHTTPRequestHandler):
|
||||
|
||||
def do_GET(self):
|
||||
|
||||
request_path = self.path
|
||||
|
||||
print("\n----- Request Start ----->\n")
|
||||
print(request_path)
|
||||
print(self.headers)
|
||||
print("<----- Request End -----\n")
|
||||
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
|
||||
def do_POST(self):
|
||||
|
||||
request_path = self.path
|
||||
|
||||
print("\n----- Request Start ----->\n")
|
||||
print(request_path)
|
||||
|
||||
request_headers = self.headers
|
||||
content_length = request_headers.getheaders('content-length')
|
||||
length = int(content_length[0]) if content_length else 0
|
||||
|
||||
print(request_headers)
|
||||
print(self.rfile.read(length))
|
||||
print("<----- Request End -----\n")
|
||||
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
|
||||
do_PUT = do_POST
|
||||
do_DELETE = do_GET
|
||||
|
||||
def main():
|
||||
port = 5001
|
||||
print('Listening on localhost:%s' % port)
|
||||
server = HTTPServer(('', port), RequestHandler)
|
||||
server.serve_forever()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = OptionParser()
|
||||
parser.usage = ("Creates an http-server that will echo out any GET or POST parameters\n"
|
||||
"Run:\n\n"
|
||||
" reflect")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
main()
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
http.ListenAndServe(":5001", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("received request:", r.Header)
|
||||
b, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer r.Body.Close()
|
||||
log.Println("request body:", string(b))
|
||||
}))
|
||||
}
|
Loading…
Reference in New Issue