Skip to content
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

[synthrace] Update entities schema #184019

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

kpatticha
Copy link
Contributor

@kpatticha kpatticha commented May 22, 2024

Summary

  1. Rename assets to entities
  2. Update synthrace to match [EEM][POC] The POC for creating entity-centric indices using entity definitions #183205
  3. Used aggregation to generate the summary metrics as used in data tranform.Timerange is not supported yet, for the rates is used 5 minutes similar to [EEM][POC] The POC for creating entity-centric indices using entity definitions #183205

How to test

Run node scripts/synthtrace.js traces_logs_assets.ts --logLevel debug --clean

Dev tools

GET .entities-synthrace.summary/_search
{}

Produces

{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 5,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": "entities-synthrace.summary",
        "_id": "GYu_uY8B8M9kC_hchEg9",
        "_score": 1,
        "_source": {
          "entity": {
            "id": "apm-only-0",
            "identity": {
              "service": {
                "environment": "Synthtrace: traces_logs_assets",
                "name": "apm-only-0"
              }
            },
            "latestTimestamp": "2024-05-27T11:10:23.765Z",
            "firstSeen": "2024-05-27T11:10:23.765Z",
            "indexPatterns": [
              "metrics-*"
            ],
            "data_stream": {
              "type": [
                "metrics"
              ]
            },
            "agent": {
              "name": "nodejs"
            },
            "metric": {
              "latency": 345500,
              "failedTransactionRate": 0.5,
              "throughput": 0.4
            }
          }
        }
      },
      {
        "_index": "entities-synthrace.summary",
        "_id": "Gou_uY8B8M9kC_hchEg9",
        "_score": 1,
        "_source": {
          "entity": {
            "id": "apm-only-1",
            "identity": {
              "service": {
                "environment": "Synthtrace: traces_logs_assets",
                "name": "apm-only-1"
              }
            },
            "latestTimestamp": "2024-05-27T11:10:23.765Z",
            "firstSeen": "2024-05-27T11:10:23.765Z",
            "indexPatterns": [
              "metrics-*"
            ],
            "data_stream": {
              "type": [
                "metrics"
              ]
            },
            "agent": {
              "name": "nodejs"
            },
            "metric": {
              "latency": 429500,
              "failedTransactionRate": 0.5,
              "throughput": 0.4
            }
          }
        }
      },
      {
        "_index": "entities-synthrace.summary",
        "_id": "G4u_uY8B8M9kC_hchEg9",
        "_score": 1,
        "_source": {
          "entity": {
            "id": "apm-only-2",
            "identity": {
              "service": {
                "environment": "Synthtrace: traces_logs_assets",
                "name": "apm-only-2"
              }
            },
            "latestTimestamp": "2024-05-27T11:10:23.765Z",
            "firstSeen": "2024-05-27T11:10:23.765Z",
            "indexPatterns": [
              "metrics-*"
            ],
            "data_stream": {
              "type": [
                "metrics"
              ]
            },
            "agent": {
              "name": "nodejs"
            },
            "metric": {
              "latency": 1034000,
              "failedTransactionRate": 0.5,
              "throughput": 0.4
            }
          }
        }
      },
      {
        "_index": "entities-synthrace.summary",
        "_id": "HIu_uY8B8M9kC_hchEg9",
        "_score": 1,
        "_source": {
          "entity": {
            "id": "multi-signal-service",
            "identity": {
              "service": {
                "environment": "Synthtrace: traces_logs_assets",
                "name": "multi-signal-service"
              }
            },
            "latestTimestamp": "2024-05-27T11:10:23.765Z",
            "firstSeen": "2024-05-27T11:10:23.765Z",
            "indexPatterns": [
              "metrics-*"
            ],
            "data_stream": {
              "type": [
                "metrics",
                "logs"
              ]
            },
            "agent": {
              "name": "nodejs"
            },
            "metric": {
              "latency": 387500,
              "failedTransactionRate": 0.5,
              "throughput": 0.4,
              "logRatePerMinute": 0.6,
              "logErrorRate": 1
            }
          }
        }
      },
      {
        "_index": "entities-synthrace.summary",
        "_id": "HYu_uY8B8M9kC_hchEg9",
        "_score": 1,
        "_source": {
          "entity": {
            "id": "logs-only-services",
            "identity": {
              "service": {
                "name": "logs-only-services"
              }
            },
            "latestTimestamp": "2024-05-27T11:10:23.765Z",
            "indexPatterns": [
              "logs-*"
            ],
            "data_stream": {
              "type": [
                "logs"
              ]
            },
            "firstSeen": "2024-05-27T11:10:23.765Z",
            "metric": {
              "logRatePerMinute": 0.6,
              "logErrorRate": 0.6666666666666666
            }
          }
        }
      }
    ]
  }
}

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@kpatticha kpatticha marked this pull request as ready for review May 27, 2024 11:19
@kpatticha kpatticha requested review from a team as code owners May 27, 2024 11:19
@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team labels May 27, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@kpatticha kpatticha added release_note:skip Skip the PR/issue when compiling release notes v8.15.0 labels May 27, 2024
@kibana-ci
Copy link
Collaborator

kibana-ci commented May 27, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #59 / InfraOps App Metrics UI Hosts View #Single Host Flyout Tabs Overview Tab should show 3 services each with an icon, service name, and url
  • [job] [logs] FTR Configs #59 / InfraOps App Metrics UI Hosts View #Single Host Flyout Tabs Overview Tab should show 3 services each with an icon, service name, and url

Metrics [docs]

Canvas Sharable Runtime

The Canvas "shareable runtime" is an bundle produced to enable running Canvas workpads outside of Kibana. This bundle is included in third-party webpages that embed canvas and therefor should be as slim as possible.

id before after diff
module count - 5412 +5412
total size - 8.8MB +8.8MB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@@ -75,19 +76,27 @@ function getAssetsFilterTransform() {
});
}

function getMergeAssetsTransform() {
const mergedDocuments: Record<string, AssetDocument> = {};
function getMergeEntitesTransform() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: typo in spelling


avg({ key }: { key: string }) {
const averageMap = new Map();
this.trackedValues.forEach((values, key) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: same name variable collision for key. Also in forEach in the rate function

* Side Public License, v 1.
*/

class PivotTransform {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given we are working with Streams here, the usage of name Transform seem misguiding. wdyt ? its actually a factory no ?

'entity.metric': {
latency: createPivotTransform(),
failedTransactionRate: createPivotTransform(),
throughput: createPivotTransform(),
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't see throughput using any of the record, avg or rate functions. Do you really want it to be a createPivotTransform

'entity.data_stream.type': ['logs'],
'entity.firstSeen': firstSeen,
'entity.metric': {
logRatePerMinute: createPivotTransform(),
Copy link
Contributor

Choose a reason for hiding this comment

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

same as throughput from the other aggregator, logRatePerMinute is not using any of the functions from this function, does it needs to be set here like this ?

@@ -45,6 +45,9 @@ export function createServiceMetricsAggregator(flushInterval: string) {
sum: 0,
value_count: 0,
},
'data_stream.type': 'metrics',
Copy link
Contributor

Choose a reason for hiding this comment

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

Any specific reason to add these 3 values to all the APM aggregators ?

Concern i see is these 3 values together represent the actual DataStream Name where documents get indexed. And we have the data stream name logic defined in the routing transform here which is different.
packages/kbn-apm-synthtrace/src/lib/apm/client/apm_synthtrace_es_client/get_routing_transform.ts

@@ -33,4 +33,4 @@ export { generateLongId, generateShortId } from './src/lib/utils/generate_id';
export { appendHash, hashKeysOf } from './src/lib/utils/hash';
export type { ESDocumentWithOperation, SynthtraceESAction, SynthtraceGenerator } from './src/types';
export { log, type LogDocument } from './src/lib/logs';
export { type AssetDocument } from './src/lib/assets';
export { type EntityDocument } from './src/lib/assets';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
export { type EntityDocument } from './src/lib/assets';
export type { EntityDocument } from './src/lib/assets';

@@ -7,6 +7,6 @@
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the file also be renamed?


export const createLogsAssetsAggregator = createAssetsAggregatorFactory<LogDocument>();
export const createLogsAssetsAggregator = createEntitiesAggregatorFactory<LogDocument>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to rename this const too?

Suggested change
export const createLogsAssetsAggregator = createEntitiesAggregatorFactory<LogDocument>();
export const createLogsEntityAggregator = createEntitiesAggregatorFactory<LogDocument>();

@@ -7,6 +7,6 @@
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the file also be renamed?

const logLevel = event['log.level']!;

// @ts-expect-error
entity['entity.metric'].logErrorRate.record({
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion to remove these ts-expect-error

Suggested change
entity['entity.metric'].logErrorRate.record({
(entity['entity.metric.logErrorRate'] ?? {}) as PivotTransform).logErrorRate.record({

const tracesGen = createGeneratorFromArray(traces);
const tracesGenAssets = createGeneratorFromArray(traces);

return [
withClient(
assetsEsClient,
entitiesEsClient,
logger.perf('generating_assets_events', () =>
Copy link
Contributor

Choose a reason for hiding this comment

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

should we change this one too?

Suggested change
logger.perf('generating_assets_events', () =>
logger.perf('generating_entities_events', () =>

@@ -15,6 +15,7 @@ import {
log,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename the scenario too?

@@ -211,13 +214,13 @@ const scenario: Scenario<ApmFields> = async (runOptions) => {
const logsGen = createGeneratorFromArray(logsValuesArray);
const logsGenAssets = createGeneratorFromArray(logsValuesArray);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const logsGenAssets = createGeneratorFromArray(logsValuesArray);
const logsGenEntities = createGeneratorFromArray(logsValuesArray);

@@ -211,13 +214,13 @@ const scenario: Scenario<ApmFields> = async (runOptions) => {
const logsGen = createGeneratorFromArray(logsValuesArray);
const logsGenAssets = createGeneratorFromArray(logsValuesArray);

const traces = instances.flatMap((instance) => instanceSpans(instance));
const traces = instances.flatMap((instance, index) => instanceSpans(instance, index));
const tracesGen = createGeneratorFromArray(traces);
const tracesGenAssets = createGeneratorFromArray(traces);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const tracesGenAssets = createGeneratorFromArray(traces);
const tracesGenEntities = createGeneratorFromArray(traces);

Comment on lines +188 to 191
entitiesSynthtraceClient.index(
Readable.from(Array.from(logsGenAssets).concat(Array.from(tracesGenAssets)))
),
logSynthtraceClient.index(logsGen),
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename these too?

Suggested change
entitiesSynthtraceClient.index(
Readable.from(Array.from(logsGenAssets).concat(Array.from(tracesGenAssets)))
),
logSynthtraceClient.index(logsGen),
entitiesSynthtraceClient.index(
Readable.from(Array.from(logsGenEntities).concat(Array.from(tracesGenEntites)))
),
logSynthtraceClient.index(logsGen),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants