Skip to content

Commit

Permalink
[Stack Monitoring] convert server/logstash dir to typescript (#110706)
Browse files Browse the repository at this point in the history
* add types to logstash server dir

* remove comment

* fix type

* remove unused type

* add helper function to test

* add issue to comment
  • Loading branch information
neptunian authored Sep 14, 2021
1 parent b610f6f commit 07f4828
Show file tree
Hide file tree
Showing 27 changed files with 667 additions and 373 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/monitoring/common/types/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export interface ElasticsearchLegacySource {
};
queue?: {
type?: string;
events?: number;
};
jvm?: {
uptime_in_millis?: number;
Expand All @@ -249,6 +250,8 @@ export interface ElasticsearchLegacySource {
};
events?: {
out?: number;
in?: number;
filtered?: number;
};
reloads?: {
failures?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export async function getClustersFromRequest(
// add logstash data
if (isInCodePath(codePaths, [CODE_PATH_LOGSTASH])) {
const logstashes = await getLogstashForClusters(req, lsIndexPattern, clusters);
const pipelines = await getLogstashPipelineIds(req, lsIndexPattern, { clusterUuid }, 1);
const pipelines = await getLogstashPipelineIds({ req, lsIndexPattern, clusterUuid, size: 1 });
logstashes.forEach((logstash) => {
const clusterIndex = clusters.findIndex(
(cluster) =>
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/server/lib/create_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function createQuery(options: {

const isFromStandaloneCluster = clusterUuid === STANDALONE_CLUSTER_CLUSTER_UUID;

let typeFilter;
let typeFilter: any;
if (type) {
typeFilter = { bool: { should: [{ term: { type } }, { term: { 'metricset.name': type } }] } };
} else if (types) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { get } from 'lodash';
import { checkParam } from '../error_missing_required';
import { getLogstashForClusters } from './get_logstash_for_clusters';
import { LegacyRequest } from '../../types';

/**
* Get the cluster status for Logstash instances.
Expand All @@ -19,9 +20,12 @@ import { getLogstashForClusters } from './get_logstash_for_clusters';
* @param {String} clusterUuid The cluster UUID for the associated Elasticsearch cluster.
* @returns {Promise} The cluster status object.
*/
export function getClusterStatus(req, lsIndexPattern, { clusterUuid }) {
export function getClusterStatus(
req: LegacyRequest,
lsIndexPattern: string,
{ clusterUuid }: { clusterUuid: string }
) {
checkParam(lsIndexPattern, 'lsIndexPattern in logstash/getClusterStatus');

const clusters = [{ cluster_uuid: clusterUuid }];
return getLogstashForClusters(req, lsIndexPattern, clusters).then((clusterStatus) =>
get(clusterStatus, '[0].stats')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const getQueueTypes = (queueBuckets: Array<Bucket & { num_pipelines: { value: nu
export function getLogstashForClusters(
req: LegacyRequest,
lsIndexPattern: string,
clusters: Cluster[]
clusters: Array<{ cluster_uuid: string } | Cluster>
) {
checkParam(lsIndexPattern, 'lsIndexPattern in logstash/getLogstashForClusters');

Expand Down
177 changes: 0 additions & 177 deletions x-pack/plugins/monitoring/server/lib/logstash/get_node_info.test.js

This file was deleted.

Loading

0 comments on commit 07f4828

Please sign in to comment.