Skip to content

CLOUDP-57855: List all available measurements for a given process, Atlas #85

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

Merged
merged 8 commits into from
Apr 3, 2020

Conversation

andreaangiolillo
Copy link
Collaborator

Proposed changes

Jira ticket: CLOUDP-57855

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • I have tested my code by using cloud-dev

Further comments

./bin/mongocli atlas measurements process cluster0-shard-00-00-ajlj3.mongodb-dev.net:27017 --granularity PT1M --projectId 5e4e593f70dfbf1010295836 -P personal --period PT1M

{
	"end": "2020-04-02T17:22:32Z",
	"granularity": "PT1M",
	"groupId": "5e4e593f70dfbf1010295836",
	"hostId": "cluster0-shard-00-00-ajlj3.mongodb-dev.net:27017",
	"links": [
		{
			"rel": "self",
			"href": "https://cloud-dev.mongodb.com/api/atlas/v1.0/groups/5e4e593f70dfbf1010295836/processes/cluster0-shard-00-00-ajlj3.mongodb-dev.net:27017/measurements?granularity=PT1M\u0026period=PT1M"
		},
		{
			"rel": "http://mms.mongodb.com/host",
			"href": "https://cloud-dev.mongodb.com/api/atlas/v1.0/groups/5e4e593f70dfbf1010295836/processes/cluster0-shard-00-00-ajlj3.mongodb-dev.net:27017"
		}
	],
	"measurements": [
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "ASSERT_REGULAR",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "ASSERT_WARNING",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "ASSERT_MSG",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "ASSERT_USER",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "CACHE_BYTES_READ_INTO",
			"units": "BYTES_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "CACHE_BYTES_WRITTEN_FROM",
			"units": "BYTES_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "CACHE_DIRTY_BYTES",
			"units": "BYTES"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "CACHE_USED_BYTES",
			"units": "BYTES"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "CONNECTIONS",
			"units": "SCALAR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "CURSORS_TOTAL_OPEN",
			"units": "SCALAR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "CURSORS_TOTAL_TIMED_OUT",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "DB_STORAGE_TOTAL",
			"units": "BYTES"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "DB_DATA_SIZE_TOTAL",
			"units": "BYTES"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "DB_INDEX_SIZE_TOTAL",
			"units": "BYTES"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "DOCUMENT_METRICS_RETURNED",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "DOCUMENT_METRICS_INSERTED",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "DOCUMENT_METRICS_UPDATED",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "DOCUMENT_METRICS_DELETED",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "EXTRA_INFO_PAGE_FAULTS",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "GLOBAL_LOCK_CURRENT_QUEUE_TOTAL",
			"units": "SCALAR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "GLOBAL_LOCK_CURRENT_QUEUE_READERS",
			"units": "SCALAR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "GLOBAL_LOCK_CURRENT_QUEUE_WRITERS",
			"units": "SCALAR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "MEMORY_RESIDENT",
			"units": "MEGABYTES"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "MEMORY_VIRTUAL",
			"units": "MEGABYTES"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "MEMORY_MAPPED",
			"units": "MEGABYTES"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "NETWORK_BYTES_IN",
			"units": "BYTES_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "NETWORK_BYTES_OUT",
			"units": "BYTES_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "NETWORK_NUM_REQUESTS",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_CMD",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_QUERY",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_UPDATE",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_DELETE",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_GETMORE",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_INSERT",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_REPL_CMD",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_REPL_UPDATE",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_REPL_DELETE",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPCOUNTER_REPL_INSERT",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OPERATIONS_SCAN_AND_ORDER",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OP_EXECUTION_TIME_READS",
			"units": "MILLISECONDS"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OP_EXECUTION_TIME_WRITES",
			"units": "MILLISECONDS"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "OP_EXECUTION_TIME_COMMANDS",
			"units": "MILLISECONDS"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": 0
				}
			],
			"name": "OPLOG_SLAVE_LAG_MASTER_TIME",
			"units": "SECONDS"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": 321
				}
			],
			"name": "OPLOG_MASTER_TIME",
			"units": "SECONDS"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": 310
				}
			],
			"name": "OPLOG_MASTER_LAG_TIME_DIFF",
			"units": "SECONDS"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": 0.000126
				}
			],
			"name": "OPLOG_RATE_GB_PER_HOUR",
			"units": "GIGABYTES_PER_HOUR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "QUERY_EXECUTOR_SCANNED",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "QUERY_EXECUTOR_SCANNED_OBJECTS",
			"units": "SCALAR_PER_SECOND"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "QUERY_TARGETING_SCANNED_PER_RETURNED",
			"units": "SCALAR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "QUERY_TARGETING_SCANNED_OBJECTS_PER_RETURNED",
			"units": "SCALAR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "TICKETS_AVAILABLE_READS",
			"units": "SCALAR"
		},
		{
			"dataPoints": [
				{
					"timestamp": "2020-04-02T17:22:32Z",
					"value": null
				}
			],
			"name": "TICKETS_AVAILABLE_WRITE",
			"units": "SCALAR"
		},
		{
			"name": "PROCESS_CPU_USER",
			"units": "PERCENT"
		},
		{
			"name": "PROCESS_CPU_KERNEL",
			"units": "PERCENT"
		},
		{
			"name": "PROCESS_CPU_CHILDREN_USER",
			"units": "PERCENT"
		},
		{
			"name": "PROCESS_CPU_CHILDREN_KERNEL",
			"units": "PERCENT"
		},
		{
			"name": "PROCESS_NORMALIZED_CPU_USER",
			"units": "PERCENT"
		},
		{
			"name": "PROCESS_NORMALIZED_CPU_KERNEL",
			"units": "PERCENT"
		},
		{
			"name": "PROCESS_NORMALIZED_CPU_CHILDREN_USER",
			"units": "PERCENT"
		},
		{
			"name": "PROCESS_NORMALIZED_CPU_CHILDREN_KERNEL",
			"units": "PERCENT"
		},
		{
			"name": "FTS_PROCESS_RESIDENT_MEMORY",
			"units": "BYTES"
		},
		{
			"name": "FTS_PROCESS_VIRTUAL_MEMORY",
			"units": "BYTES"
		},
		{
			"name": "FTS_PROCESS_SHARED_MEMORY",
			"units": "BYTES"
		},
		{
			"name": "FTS_DISK_USAGE",
			"units": "BYTES"
		},
		{
			"name": "FTS_PROCESS_CPU_USER",
			"units": "PERCENT"
		},
		{
			"name": "FTS_PROCESS_CPU_KERNEL",
			"units": "PERCENT"
		},
		{
			"name": "FTS_PROCESS_NORMALIZED_CPU_USER",
			"units": "PERCENT"
		},
		{
			"name": "FTS_PROCESS_NORMALIZED_CPU_KERNEL",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_CPU_USER",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_CPU_KERNEL",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_CPU_NICE",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_CPU_IOWAIT",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_CPU_IRQ",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_CPU_SOFTIRQ",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_CPU_GUEST",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_CPU_STEAL",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_NORMALIZED_CPU_USER",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_NORMALIZED_CPU_KERNEL",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_NORMALIZED_CPU_NICE",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_NORMALIZED_CPU_IOWAIT",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_NORMALIZED_CPU_IRQ",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_NORMALIZED_CPU_SOFTIRQ",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_NORMALIZED_CPU_GUEST",
			"units": "PERCENT"
		},
		{
			"name": "SYSTEM_NORMALIZED_CPU_STEAL",
			"units": "PERCENT"
		}
	],
	"processId": "cluster0-shard-00-00-ajlj3.mongodb-dev.net:27017",
	"start": "2020-04-02T17:22:32Z"
}

@andreaangiolillo andreaangiolillo added the WIP Work in progress label Apr 2, 2020
@@ -53,6 +53,7 @@ A user’s roles apply to all the clusters in the project.`
ListDBUsers = "List Atlas database users for a project."
ListEvents = "List events for an organization or project"
UpdateDBUser = "Update a MongoDB dbuser in Atlas."
ProcessMeasurements = "Get process measurements."
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am happy to change these descriptions

Copy link
Collaborator

Choose a reason for hiding this comment

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

what about "Get measurements for a given host" ?

@andreaangiolillo andreaangiolillo requested a review from gssbzn April 2, 2020 17:34
@andreaangiolillo andreaangiolillo removed the WIP Work in progress label Apr 2, 2020
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

Couple of nit but in general great first approach

return json.PrettyPrint(result)
}

func (opts *atlasMeasurementsProcessOpts) newHostInfo() (*hostInfo, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q] do you have more plans fro hostInfo?
I'd rather take advantage of go multi return and do something like

func (opts *atlasMeasurementsProcessOpts) getHostNameAndPort() (string, int, error)

but up to you if you think that having the helper struct helps
if you want to keep the helper struct another thing you could do is define just

func newHostInfo(host string)(*hostInfo, error)

and not link it to atlasMeasurementsProcessOpts this may let you reuse it in other contexts

func (opts *atlasMeasurementsProcessOpts) newHostInfo() (*hostInfo, error) {
host := strings.SplitN(opts.host, ":", -1)
if len(host) != 2 {
return nil, errors.New("the host information must be in the format host:port")
Copy link
Collaborator

Choose a reason for hiding this comment

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

small nit on usuability, let's return something like

fmt.Errorf("expected hostname:port, got %s", host)

return opts.init()
},
RunE: func(cmd *cobra.Command, args []string) error {
opts.host = args[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] depending on how you handle my above changes (function return string:int vs newHostInfo) you could change this to do that process here since you have no use for opts.host rather than to parse it later
with this I mean you could fo

opt.host, opt.port, err = opts.getHostAndPort(args[0])

Or

opt.hostInfo, err = newHostInfo(args[0])

@@ -53,6 +53,7 @@ A user’s roles apply to all the clusters in the project.`
ListDBUsers = "List Atlas database users for a project."
ListEvents = "List events for an organization or project"
UpdateDBUser = "Update a MongoDB dbuser in Atlas."
ProcessMeasurements = "Get process measurements."
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about "Get measurements for a given host" ?

@andreaangiolillo andreaangiolillo requested a review from gssbzn April 3, 2020 11:41
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

Almost there, just some small missing things


port, err := strconv.Atoi(host[1])
if err != nil {
return "", 0, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as before, could we improve on the error and show something like, invalid port number, got %s

globalOpts: newGlobalOpts(),
}
cmd := &cobra.Command{
Use: "process",
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are missing the alias here

return json.PrettyPrint(result)
}

func (opts *atlasMeasurementsProcessOpts) getHostNameAndPort(hostInfo string) (string, int, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] this could be just

Suggested change
func (opts *atlasMeasurementsProcessOpts) getHostNameAndPort(hostInfo string) (string, int, error) {
func getHostNameAndPort(hostInfo string) (string, int, error) {

since you don't use opts in the body

Copy link
Collaborator

Choose a reason for hiding this comment

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

this also let's you reuse it later, we have a bunch of commands that may need this great method ;)

@andreaangiolillo andreaangiolillo requested a review from gssbzn April 3, 2020 14:24
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

@andreaangiolillo andreaangiolillo merged commit eeba392 into master Apr 3, 2020
@andreaangiolillo andreaangiolillo deleted the CLOUDP-57855 branch April 3, 2020 14:27
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.

2 participants