Skip to content
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

[Adding] Accountz monitoring endpoint and INFO monitoring req subject #1611

Merged
merged 2 commits into from
Sep 24, 2020

Conversation

matthiashanel
Copy link
Contributor

Returned imports/exports are formatted like jwt exports imports, even if they originating account is from config.
Fixes #1604

Signed-off-by: Matthias Hanel mh@synadia.com

I named the account specific subject INFO as it makes more sense than ACCOUNTZ.
ForCONNZ/SUBSZ we remain to have the plural even when scoped to the account, not so much for account itself.

Also setting update time on every update and account creation. (avoids empty values)
For consistency, setting incomplete when expired (dummy) account is created.
This is primarily to make the returned json make sense and look somewhat similar no matter the origin (jwt/cfg)

http://localhost:7222/accountz

{
  "server_id": "NDSVJWYHPIXEYV3PS66X4V2PUWWYVQVPQUJ35FZJRI5PN6QMWBHJ2MZH",
  "now": "2020-09-23T16:18:53.199956-04:00",
  "accounts": [
    "SYS",
    "$G",
    "USERS"
  ]
}
http://localhost:7222/accountz?acc=SYS

{
  "server_id": "NDSVJWYHPIXEYV3PS66X4V2PUWWYVQVPQUJ35FZJRI5PN6QMWBHJ2MZH",
  "now": "2020-09-23T16:19:56.311826-04:00",
  "account_detail": {
    "account_name": "SYS",
    "update_time": "2020-09-23T16:18:44.089969-04:00",
    "expired": false,
    "complete": true,
    "jetstream_enabled": false,
    "leafnode_connections": 0,
    "client_connections": 0,
    "subscriptions": 32,
    "exports": [
      {
        "subject": "$SYS.DEBUG.SUBSCRIBERS",
        "type": "service",
        "response_type": "Singleton",
        "approved_accounts": []
      }
    ],
    "imports": []
  }
}

Returned imports/exports are formated like jwt exports imports, even if
they originating account is from config.

Fixes #1604

Signed-off-by: Matthias Hanel <mh@synadia.com>
Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments about the json tags.

server/monitor.go Outdated Show resolved Hide resolved

type ExtExport struct {
jwt.Export
ApprovedAccounts []string `json:"approved_accounts"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and almost all of them in AccountInfo, you seem to not use ,omitempty. Is there a reason? The boolean and int, if 0, could be omitted, which will make the JSON marshal smaller. Same for list of exports and imports (Exps, Imps, which by the way could probably be spelled out: Exports and Imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used omitempty sparingly because I imagine this to be used for debugging.
For this use case I imagine having values be explicitly listed makes more sense.
I used it only in cases where the source of the account makes a difference (jwt or config), which is also why I'll add it to this field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'll can add it everywhere. Your call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if explicitly listed but equal to the type uninitialized value (false for boolean, 0 for numbers, etc), you would really not know the difference. Meaning if you see say "expired: false", I am not even sure what that would mean to be set explicitly.

Or here, approved_accounts, if you don't see it it means it was nil. What difference (except for marshal result being bigger) would that make to get approved_accounts received as []string{} (or nil).

If you could give me an example of a case where having without omitempty would help debug as opposed to if the field had omitempty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically cut down on time spent trying to find out what should be there. If you don't think that matters I'll put omitempty on every field.

approved_accounts I added it already.

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

expose account specific monitoring/debugging information as system service
2 participants