diff --git a/web/src/main/angular/src/app/core/components/agent-statistic-chart/agent-statistic-chart-container.component.ts b/web/src/main/angular/src/app/core/components/agent-statistic-chart/agent-statistic-chart-container.component.ts index 0189cf93682e..33d0057a13cb 100644 --- a/web/src/main/angular/src/app/core/components/agent-statistic-chart/agent-statistic-chart-container.component.ts +++ b/web/src/main/angular/src/app/core/components/agent-statistic-chart/agent-statistic-chart-container.component.ts @@ -27,12 +27,12 @@ export class AgentStatisticChartContainerComponent implements OnInit { ngOnInit() { this.emptyText$ = this.translateService.get('COMMON.NO_DATA'); this.chartData$ = this.storeHelperService.getAgentList(this.unsubscribe).pipe( - filter((data: IAgentList) => !!data), - map((data: IAgentList) => this.makeChartData(data)) + filter((data: IServerAndAgentDataV2[]) => !!data), + map((data: IServerAndAgentDataV2[]) => this.makeChartData(data)) ); } - private makeChartData(data: IAgentList): {[key: string]: PrimitiveArray[]} { + private makeChartData(data: IServerAndAgentDataV2[]): {[key: string]: PrimitiveArray[]} { if (isEmpty(data)) { return { jvm: [], @@ -55,11 +55,11 @@ export class AgentStatisticChartContainerComponent implements OnInit { * } */ let count = 0; - const dataObj = Object.keys(data).reduce((acc1: {[key: string]: any}, appKey: string) => { - const app = data[appKey]; - return app.reduce((acc2: {[key: string]: any}, {agentVersion, jvmInfo}: IAgent) => { + const dataObj = data.reduce((acc1: {[key: string]: any}, {instancesList}: IServerAndAgentDataV2) => { + return instancesList.reduce((acc2: {[key: string]: any}, {agentVersion, jvmInfo}: IAgentDataV2) => { count++; + if (agentVersion) { acc2['agent'][agentVersion] = (acc2['agent'][agentVersion] || 0) + 1; } @@ -71,7 +71,7 @@ export class AgentStatisticChartContainerComponent implements OnInit { return acc2; }, acc1); - }, {jvm: {}, agent: {}}) as {[key: string]: {[key: string]: number}}; + }, {jvm: {}, agent: {}}) const sortedDataObj = Object.entries(dataObj).reduce((acc1: {[key: string]: Map}, [key, valueObj]: [string, {[key: string]: number}]) => { const sortedChildMap = new Map(Object.entries(valueObj).sort(([k1], [k2]) => k1 < k2 ? -1 : 1)); diff --git a/web/src/main/angular/src/app/core/components/agent-statistic-list/agent-statistic-list-container.component.ts b/web/src/main/angular/src/app/core/components/agent-statistic-list/agent-statistic-list-container.component.ts index 126c0deba638..a7ffc4283245 100644 --- a/web/src/main/angular/src/app/core/components/agent-statistic-list/agent-statistic-list-container.component.ts +++ b/web/src/main/angular/src/app/core/components/agent-statistic-list/agent-statistic-list-container.component.ts @@ -25,7 +25,7 @@ export class AgentStatisticListContainerComponent implements OnInit, OnDestroy { ngOnInit() { this.agentListData$ = this.storeHelperService.getAgentList(this.unsubscribe).pipe( - map((data: IAgentList) => this.makeGridData(data)) + map((data: IServerAndAgentDataV2[]) => this.makeGridData(data)) ); } @@ -34,33 +34,27 @@ export class AgentStatisticListContainerComponent implements OnInit, OnDestroy { this.unsubscribe.complete(); } - private makeGridData(agentList: IAgentList): IGridData[] { + private makeGridData(data: IServerAndAgentDataV2[]): IGridData[] { let index = 1; const resultData: IGridData[] = []; - Object.keys(agentList).forEach((key: string, innerIndex: number) => { - const list: IAgent[] = agentList[key]; + data.forEach(({instancesList}: IServerAndAgentDataV2) => { let row: IGridData; - if (list.length === 0) { - row = this.makeRow(list[0], index, false, false); + instancesList.forEach((agent: IAgentDataV2, agentIndex: number) => { + if (agentIndex === 0) { + row = this.makeRow(agent, index, true, false); + } else { + row.children.push(this.makeRow(agent, index, false, true)); + } index++; - } else { - list.forEach((agent: IAgent, agentIndex: number) => { - if (agentIndex === 0) { - row = this.makeRow(agent, index, true, false); - } else { - row.children.push(this.makeRow(agent, index, false, true)); - } - index++; - }); - } + }); resultData.push(row); }); return resultData; } - private makeRow(agent: IAgent, index: number, hasChild: boolean, isChild: boolean): any { + private makeRow(agent: IAgentDataV2, index: number, hasChild: boolean, isChild: boolean): any { const oRow: IGridData = { index: index, application: agent.applicationName, diff --git a/web/src/main/angular/src/app/core/components/configuration-agent-statistic/agent-statistic-data.service.ts b/web/src/main/angular/src/app/core/components/configuration-agent-statistic/agent-statistic-data.service.ts index b8e650d8400f..eb62682026d9 100644 --- a/web/src/main/angular/src/app/core/components/configuration-agent-statistic/agent-statistic-data.service.ts +++ b/web/src/main/angular/src/app/core/components/configuration-agent-statistic/agent-statistic-data.service.ts @@ -5,15 +5,15 @@ import { tap } from 'rxjs/operators'; @Injectable() export class AgentStatisticDataService { - private url = 'getAgentList.pinpoint'; + private url = 'agents/statistics.pinpoint'; private lastRequestTime: number; constructor( private http: HttpClient ) {} - getData(): Observable { - return this.http.get(this.url).pipe( + getData(): Observable { + return this.http.get(this.url).pipe( tap(() => { this.lastRequestTime = new Date().getTime(); }) diff --git a/web/src/main/angular/src/app/core/components/configuration-agent-statistic/configuration-agent-statistic-container.component.ts b/web/src/main/angular/src/app/core/components/configuration-agent-statistic/configuration-agent-statistic-container.component.ts index 79274f836aac..0a321f6857d5 100644 --- a/web/src/main/angular/src/app/core/components/configuration-agent-statistic/configuration-agent-statistic-container.component.ts +++ b/web/src/main/angular/src/app/core/components/configuration-agent-statistic/configuration-agent-statistic-container.component.ts @@ -43,7 +43,7 @@ export class ConfigurationAgentStatisticContainerComponent implements OnInit, On tap(() => { this.lastRequestTime = moment(this.agentStatisticDataService.getLastRequestTime()).tz(this.timezone).format(this.dateFormat); }), - map((data: IAgentList) => !!data) + map((data: IServerAndAgentDataV2[]) => !!data) ); } @@ -80,7 +80,7 @@ export class ConfigurationAgentStatisticContainerComponent implements OnInit, On this.showProcessing(); this.agentStatisticDataService.getData().pipe( takeUntil(this.unsubscribe) - ).subscribe((agentList: IAgentList) => { + ).subscribe((agentList: IServerAndAgentDataV2[]) => { this.storeHelperService.dispatch(new Actions.UpdateAdminAgentList(agentList)); this.hideProcessing(); }, (error: IServerError) => { diff --git a/web/src/main/angular/src/app/shared/services/store-helper.service.ts b/web/src/main/angular/src/app/shared/services/store-helper.service.ts index ced33aeeacd9..07c688283b89 100644 --- a/web/src/main/angular/src/app/shared/services/store-helper.service.ts +++ b/web/src/main/angular/src/app/shared/services/store-helper.service.ts @@ -108,7 +108,7 @@ export class StoreHelperService { }) ); } - getAgentList(unsubscribe: Subject): Observable { + getAgentList(unsubscribe: Subject): Observable { return this.getObservable(STORE_KEY.ADMIN_AGENT_LIST, unsubscribe); } getAgentSelection(unsubscribe: Subject): Observable { diff --git a/web/src/main/angular/src/app/shared/store/reducers/admin.reducer.ts b/web/src/main/angular/src/app/shared/store/reducers/admin.reducer.ts index c451bc9bd5f4..c70a9a17f9ba 100644 --- a/web/src/main/angular/src/app/shared/store/reducers/admin.reducer.ts +++ b/web/src/main/angular/src/app/shared/store/reducers/admin.reducer.ts @@ -3,10 +3,10 @@ import { Action } from '@ngrx/store'; const UPDATE_ADMIN_AGENT_LIST = 'UPDATE_ADMIN_AGENT_LIST'; export class UpdateAdminAgentList implements Action { readonly type = UPDATE_ADMIN_AGENT_LIST; - constructor(public payload: IAgentList) {} + constructor(public payload: IServerAndAgentDataV2[]) {} } -export function Reducer(state: IAgentList, action: UpdateAdminAgentList): IAgentList { +export function Reducer(state: IServerAndAgentDataV2[], action: UpdateAdminAgentList): IServerAndAgentDataV2[] { switch (action.type) { case UPDATE_ADMIN_AGENT_LIST: return action.payload; diff --git a/web/src/main/angular/src/globals.d.ts b/web/src/main/angular/src/globals.d.ts index ddeab7b7e379..e2baf5d65f0b 100644 --- a/web/src/main/angular/src/globals.d.ts +++ b/web/src/main/angular/src/globals.d.ts @@ -336,20 +336,25 @@ interface IServerAndAgentDataV2 { } interface IAgentDataV2 { + applicationName: string; agentId: string; agentName: string; - agentVersion: string; - applicationName: string; - container: boolean; + startTimestamp: number; hostName: string; ip: string; - linkList: any[]; - pid: number; ports: string; serviceType: string; + pid: number; + vmVersion: string; + agentVersion: string; + container: boolean; serviceTypeCode: number; - startTimestamp: number; - status: { + jvmInfo?: { + version: number; + jvmVersion: string; + gcTypeName: string; + }; + status?: { agentId: string; eventTimestamp: number; state: { @@ -357,7 +362,7 @@ interface IAgentDataV2 { desc: string; } }; - vmVersion: string; + linkList?: any[]; } // @store diff --git a/web/src/main/angular/src/proxy.conf.js b/web/src/main/angular/src/proxy.conf.js index 14b8138febeb..979c5d1ece8b 100644 --- a/web/src/main/angular/src/proxy.conf.js +++ b/web/src/main/angular/src/proxy.conf.js @@ -71,7 +71,8 @@ const PROXY_CONFIG = [ "/uriStat/top50.pinpoint", "/uriStat/chart.pinpoint", "/agents/search-all", - "/agents/search-application" + "/agents/search-application", + "/agents/statistics" ], target: 'http://localhost:8080', secure: false