-
Notifications
You must be signed in to change notification settings - Fork 2
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
Added "SHOW RESOURCE MONITORS" #8
Conversation
@paulsewardasc Awesome to see this PR. Thank you 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @paulsewardasc , thanks for working on adding this table and opening a PR!
I've added some comments and suggestions, can you please have a look at them when you get a chance? If you have any questions, please let me know!
README.md
Outdated
@@ -31,7 +31,32 @@ where | |||
(last_success_login > now() - interval '30 days') | |||
and last_success_login is not null; | |||
``` | |||
## Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding examples here, can you please create a new table document, e.g., https://github.com/turbot/steampipe-plugin-snowflake/blob/main/docs/tables/snowflake_database.md? These docs are helpful as they show up on https://hub.steampipe.io/plugins/turbot/snowflake/tables.
Also, for the examples, can you please follow our standard formatting as per Table Documentation Standards?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulsewardasc Did you push up the new commit yet? I don't see it in the Commits
list yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is here, do I need to do something else? It may not have been here last night.
https://github.com/paulsewardasc/steampipe-plugin-snowflake/tree/resource_monitors
return nil, nil | ||
} | ||
|
||
func ScanResourceMonitor(row *sqlx.Row) (*ResourceMonitor, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this function used anywhere? If not, can you please remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
|
||
type ResourceMonitor struct { | ||
Name sql.NullString `json:"name" db:"name"` | ||
CreditQuota sql.NullString `json:"credit_quota" db:"credit_quota"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the formatting looks a bit off here, can you please run gofmt -w <filename>
to update the file to use the standard Go formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{Name: "frequency", Type: proto.ColumnType_STRING, Description: "Daily, Weekly, etc"}, | ||
{Name: "start_time", Type: proto.ColumnType_TIMESTAMP, Description: "Date and time when the monitor was started."}, | ||
{Name: "end_time", Type: proto.ColumnType_TIMESTAMP, Description: "Date and time when the monitor was stopped."}, | ||
{Name: "notify_at", Type: proto.ColumnType_STRING, Description: "Levels to which to alert"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{Name: "notify_at", Type: proto.ColumnType_STRING, Description: "Levels to which to alert"}, | |
{Name: "notify_at", Type: proto.ColumnType_STRING, Description: "Levels to which to alert."}, |
Please see Table and Column Descriptions for more information on formatting descriptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
func tableSnowflakeResourceMonitor(_ context.Context) *plugin.Table { | ||
return &plugin.Table{ | ||
Name: "snowflake_resource_monitors", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name: "snowflake_resource_monitors", | |
Name: "snowflake_resource_monitor", |
Can you please make the table name singular?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done although the command run is "SHOW RESOURCE MONITORS"
EndTime sql.NullTime `json:"end_time" db:"end_time"` | ||
NotifyAt sql.NullString `json:"notify_at" db:"notify_at"` | ||
SuspendAt sql.NullString `json:"suspend_at" db:"suspend_at"` | ||
SuspendImdAt sql.NullString `json:"suspend_immediately_at" db:"suspend_immediately_at"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SuspendImdAt sql.NullString `json:"suspend_immediately_at" db:"suspend_immediately_at"` | |
SuspendImmediatelyAt sql.NullString `json:"suspend_immediately_at" db:"suspend_immediately_at"` |
We prefer to use full names (even if they're a bit long) so there's no ambiguity and all names are consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
logger := plugin.Logger(ctx) | ||
db, err := connect(ctx, d) | ||
if err != nil { | ||
logger.Error("snowflake_warehouse.listSnowflakeResourceMonitors", "connnection.error", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.Error("snowflake_warehouse.listSnowflakeResourceMonitors", "connnection.error", err) | |
logger.Error("snowflake_resource_monitor.listSnowflakeResourceMonitors", "connnection.error", err) |
Can you please fix other logging statements like this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
defer rows.Close() | ||
|
||
dbs := []ResourceMonitor{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dbs := []ResourceMonitor{} | |
resourceMonitors := []ResourceMonitor{} |
We should match the variable name more closely with what we're retrieving
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulsewardasc Thanks for making the updates quickly! I've added a few more suggestions/comments, but I believe these should be the latest round of suggestions.
Can you please have a look when you get a chance? If you have any questions, please let me know.
{Name: "end_time", Type: proto.ColumnType_TIMESTAMP, Description: "Date and time when the monitor was stopped."}, | ||
{Name: "notify_at", Type: proto.ColumnType_STRING, Description: "Levels to which to alert."}, | ||
{Name: "suspend_at", Type: proto.ColumnType_STRING, Description: "Levels to which to suspend warehouse"}, | ||
{Name: "suspend_immediately_at", Type: proto.ColumnType_STRING, Description: "Levels to which to suspend warehouse"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this column's value ever have more than 1 level at which the warehouse will be suspended? If so, is it a comma delimited list (or a list with another delimiter)? Going off of the description, it seems like we could expect more than 1 level.
Do you have a link to where you pulled this description from? That may be helpful for me to compare the current descriptions vs. what the docs/other sources mention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This column can have 1 or more values, having problems compiling the code at the moment, the function keeps show the show warehouse schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulsewardasc Are you still having troubles compiling the plugin? Please let me know here or over Slack if there's anything I can help with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it, the plugin.go file was wrong!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The credit_quota is defined in snowflake as a variant data type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The remaining_credits is defined as a float and suspend is a NUMBER(38,0) is that helps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
READER_ACCOUNT_NAME VARCHAR(16777216)
NAME VARCHAR(16777216)
CREATED TIMESTAMP_LTZ(6)
CREDIT_QUOTA VARIANT
USED_CREDITS VARIANT
REMAINING_CREDITS FLOAT
OWNER VARCHAR(16777216)
WAREHOUSES VARCHAR(16777216)
NOTIFY NUMBER(38,0)
SUSPEND NUMBER(38,0)
SUSPEND_IMMEDIATE NUMBER(38,0)
LEVEL VARCHAR(9)
READER_ACCOUNT_DELETED_ON TIMESTAMP_LTZ(6)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the credit_quota
column, I think OK to leave as a double. In the example query results you added, they appear to be integers instead of doubles, but if there's a possibility there's precision as per https://docs.snowflake.com/en/sql-reference/data-types-numeric.html#number, then double is correct.
For notfiy_at
, suspend_at
, and suspend_at_immediately
, do you have example query results that include single value and multi-value rows? I'd be curious to see how the data looks since the column types are currently marked as STRING, but if there can be multiple values, should the column types be JSON instead (which handles arrays)?
Hey @paulsewardasc , thanks for the quick updates a few days ago! I believe the last set of questions I have before I'm ready to approve is mentioned in #8 (comment), when you get a chance can you please have a look? If there's anything I can expand on, please let me know. Thanks! |
Hi, I am not sure what I need to do, I have added an example. |
@paulsewardasc Sorry about that, I didn't realize you updated the PR comment/description with a new example showing those columns, I was originally looking in the review comment chain where I asked for the examples. Based on the examples, the column type STRING makes sense. |
@paulsewardasc Thanks for creating the PR and working through the various reviews! We really appreciate the contribution and plan to release a new version of this plugin this week. |
Example query results
Results