Skip to content

Add metrics and RT monitoring #266

Open
@alonkashtan

Description

Hi,
I would like to add metrics to allow RT monitoring, to allow automatic & manual test on remote servers verify that the traffic is actually passing through toxiproxy, verify that they stop, see clients connects and disconnects and so on.
I've been experimenting with the code and got something working, and would like to consult before I create a PR.

The functionality I added does as follows:

  • added a /metrics endpoint that returns a map that describes the number of total messages per proxy.
  • added a /events endpoint that returns a list of messages (proxy, client, upstream, event type and timestamp) for up to 20 minutes ago. A token is returned with each response that can be used in the next request to receive only unseen events.

The way I did it is by creating a metrics module, with a RegisterEvent method. In proxy.go I report when client connects, in link.go I report that a clients disconnects.

Things got trickier when trying to report messages. I used the fact that noop toxic is always present to report from there. The problem is that noop toxic doesn't have any context to its work, so I had to add ProxyName and Upstream to NoopProxy, and had to pass this information on to and from where it is created, namely Link and ToxicStub.

Does this make sense? In addition, I wasn't able to tell in NoopProxy which client sent a specific message. Any idea how can I do that?

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions