-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Stack Monitoring] Converts logstash api routes to typescript #131946
[Stack Monitoring] Converts logstash api routes to typescript #131946
Conversation
@@ -142,6 +142,14 @@ export interface ElasticsearchIndexStats { | |||
}; | |||
} | |||
|
|||
export interface ElasticsearchLogstashStatePipeline { |
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.
I've created this type to improve the return type readability on getPipeline
function
return getLogstashForClusters(req, clusters).then((clusterStatus) => | ||
get(clusterStatus, '[0].stats') | ||
return getLogstashForClusters(req, clusters).then( | ||
(clusterStatus) => clusterStatus && clusterStatus[0]?.stats |
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.
I've seen lodash
being removed somewhere else. I thinks this way is safe
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.
There was no defaultValue
passed to get
so this LGTM.
|
||
try { | ||
const [pipeline, vertex] = await Promise.all(promises); | ||
const [pipeline, vertex] = await Promise.all([ |
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 is like this so that ts
can be able to infer the correct type of pipeline
and vertex
} from '../../../../../../common/http_api/logstash'; | ||
|
||
const throughputMetric = 'logstash_cluster_pipeline_throughput'; | ||
const nodesCountMetric = 'logstash_cluster_pipeline_node_count'; |
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.
Previously, this was logstash_cluster_pipeline_nodes_count. However this is not a valid type (see: here). So we need to either include logstash_cluster_pipeline_nodes_count
to the union or use a valid option here.
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.
I actually had to add logstash_cluster_pipeline_nodes_count
to PipelineNodeCountMetricKey
. The endpoint was returning 500 when logstash_cluster_pipeline_node_count
was passed
} from '../../../../../../common/http_api/logstash'; | ||
|
||
const throughputMetric = 'logstash_node_pipeline_throughput'; | ||
const nodesCountMetric = 'logstash_node_pipeline_node_count'; |
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.
Previously, this was logstash_node_pipeline_nodes_count. However this is not a valid type (see: here). So we need to either include logstash_node_pipeline_nodes_count
to the union or use a valid option here.
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.
I actually had to add logstash_node_pipeline_nodes_count
to PipelineNodeCountMetricKey
. The endpoint was returning 500 when logstash_node_pipeline_nodes_count
was passed
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
rt.partial({ | ||
ccs: ccsRT, | ||
sort: sortingRT, | ||
queryText: rt.string, |
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 original type had a default value of ''
when queryText
was not sent. Should we have this validation here?
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.
As queryText
can sometimes not be sent, having it as optional here on the io-ts request payload type seems accurate to me. Imo, it should fall to other functions to then check for that and hand what is needed to other call sites.
@elasticmachine merge upstream |
a4b3621
to
411fc59
Compare
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment 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.
Great work, LGTM 🙌
Thanks for the additional improvements (removing Lodash and so on).
rt.partial({ | ||
ccs: ccsRT, | ||
sort: sortingRT, | ||
queryText: rt.string, |
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.
As queryText
can sometimes not be sent, having it as optional here on the io-ts request payload type seems accurate to me. Imo, it should fall to other functions to then check for that and hand what is needed to other call sites.
return getLogstashForClusters(req, clusters).then((clusterStatus) => | ||
get(clusterStatus, '[0].stats') | ||
return getLogstashForClusters(req, clusters).then( | ||
(clusterStatus) => clusterStatus && clusterStatus[0]?.stats |
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.
There was no defaultValue
passed to get
so this LGTM.
Summary
This converts the logstash api routes to TypeScript.
closes #117763
Additional nodes
Logstash api folder has a sub directory called
pipelines
. I'm not sure if we should keep it like thas, but I didn't change the folder structure. I've decided not to create a subdirectory in the newhttp_api
directory structure to add the new type definitions.