{"version":18,"variables":[{"key":"User","visible":true,"type":"code","version":1,"editable":true,"input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  const groupByField = 'user'; // 👈 Cambiá acá por el campo deseado\n\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    while (next) {\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  const data = await fetchAllAuditLogs({\n    filter: '',\n    from: $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // Extraer valores únicos del campo seleccionado\n  const uniqueValues = data\n    .map(item => item[groupByField] ?? 'UNKNOWN')\n    .filter((value, index, self) => value && self.indexOf(value) === index)\n    .sort((a, b) => a.localeCompare(b));\n\n  return uniqueValues;\n}\n","multiple":true,"defaultValue":["3420b2ac-f1cf-4b24-b62d-61ba1ba8ed05*"]},{"key":"EventType","visible":true,"type":"code","version":1,"editable":true,"input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  const groupByField = 'eventType'; // 👈 Cambiá acá por el campo deseado\n\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    while (next) {\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  const data = await fetchAllAuditLogs({\n    filter: '',\n    from: $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // Extraer valores únicos del campo seleccionado\n  const uniqueValues = data\n    .map(item => item[groupByField] ?? 'UNKNOWN')\n    .filter((value, index, self) => value && self.indexOf(value) === index)\n    .sort((a, b) => a.localeCompare(b));\n\n  return uniqueValues;\n}\n","multiple":true,"defaultValue":["3420b2ac-f1cf-4b24-b62d-61ba1ba8ed05*"]},{"key":"Category","visible":true,"type":"code","version":1,"editable":true,"input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  const groupByField = 'category'; // 👈 Cambiá acá por el campo deseado\n\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    while (next) {\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  const data = await fetchAllAuditLogs({\n    filter: '',\n    from: $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // Extraer valores únicos del campo seleccionado\n  const uniqueValues = data\n    .map(item => item[groupByField] ?? 'UNKNOWN')\n    .filter((value, index, self) => value && self.indexOf(value) === index)\n    .sort((a, b) => a.localeCompare(b));\n\n  return uniqueValues;\n}\n","multiple":true,"defaultValue":["3420b2ac-f1cf-4b24-b62d-61ba1ba8ed05*"]},{"key":"EntityId","visible":true,"type":"code","version":1,"editable":true,"input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  const groupByField = 'entityId'; // 👈 Cambiá acá por el campo deseado\n\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    while (next) {\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  const data = await fetchAllAuditLogs({\n    filter: '',\n    from: $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // Extraer valores únicos del campo seleccionado\n  const uniqueValues = data\n    .map(item => item[groupByField] ?? 'UNKNOWN')\n    .filter((value, index, self) => value && self.indexOf(value) === index)\n    .sort((a, b) => a.localeCompare(b));\n\n  return uniqueValues;\n}\n","multiple":true,"defaultValue":["3420b2ac-f1cf-4b24-b62d-61ba1ba8ed05*"]},{"key":"Time","visible":true,"type":"csv","version":1,"editable":true,"input":"day,hour,minute","multiple":false,"defaultValue":"day"}],"tiles":{"9":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Función para normalizar timestamps a \"YYYY-MM-DDTHH:MM\"\n  function normalizeToMinute(value) {\n    const epochMs = typeof value === 'string'\n      ? new Date(value).getTime()\n      : value > 1e12 ? value : value * 1000;\n\n    const date = new Date(epochMs);\n    return date.toISOString().substring(0, 16);\n  }\n\n  // 👉 Función para inferir tipo automáticamente\n  function inferType(value) {\n    if (typeof value === 'number') {\n      if (value > 1e12 || (value > 1e9 && value < 1e12)) return 'timestamp';\n      return 'long';\n    }\n    if (typeof value === 'string') {\n      if (/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}/.test(value)) return 'timestamp';\n      return 'string';\n    }\n    return 'string';\n  }\n\n  // 🔁 Función flexible de agrupación + tipado\n  function buildDataFrameAdvanced(data, groupByFields = []) {\n    const grouped = {};\n\n    data.forEach(item => {\n      const keyParts = groupByFields.map(field => {\n        const value = item[field] ?? 'UNKNOWN';\n        return field === 'timestamp' ? normalizeToMinute(value) : value;\n      });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields.forEach((field, i) => {\n          record[field] = values[i];\n        });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields.reduce((acc, field) => {\n      acc[field] = { type: inferType(sample[field]) };\n      return acc;\n    }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Función para traer todos los registros de auditoría\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(config)\n\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    console.log(firstresponse)\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 📦 Ejecutar y agrupar por campos deseados\n  const data = await fetchAllAuditLogs({\n    filter: '',\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // Cambiá los campos como gustes: eventType, user, timestamp, success, etc.\n  const groupedData = buildDataFrameAdvanced(data, ['eventType']);\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"vertical","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxis":["eventType"],"valueAxis":["count"],"categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single","isCategoryLabelVisible":false,"isValueLabelVisible":true},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{},"legend":{"position":"auto","hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["eventType"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto"},"tooltip":{"showCustomFields":false},"unitsOverrides":[]}},"17":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            // value = value \n            value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"position":"auto","hidden":false}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"18":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            // value = value \n            value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user'],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"user","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["user"],"valueAxis":["count"]},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":32},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"19":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"LOGIN\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['eventType' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"singleValue","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[{"id":1,"field":"count","title":"","isEnabled":true,"rules":[]}],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{}},"singleValue":{"showLabel":false,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"count","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"eventType"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":17},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"20":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"LOGOUT\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['eventType' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"count","title":"","isEnabled":true,"rules":[{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{}},"singleValue":{"showLabel":false,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"count","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"eventType"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":17},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"21":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"UPDATE\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['eventType' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"count","title":"","isEnabled":true,"rules":[{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{}},"singleValue":{"showLabel":false,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"count","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"eventType"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":17},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"22":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"CREATE\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['eventType' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"count","title":"","isEnabled":true,"rules":[{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{}},"singleValue":{"showLabel":false,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"count","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"eventType"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":17},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"23":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"DELETE\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['eventType' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"count","title":"","isEnabled":true,"rules":[{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{}},"singleValue":{"showLabel":false,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"count","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"eventType"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":17},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"24":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"GENERAL\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['eventType' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"count","title":"","isEnabled":true,"rules":[{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{}},"singleValue":{"showLabel":false,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"count","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"eventType"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":17},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"26":{"title":"","type":"data","query":"data record( nombre=\"Login\" )","visualization":"singleValue","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-03-default, #2a7453)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AccountFilledIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"}},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"27":{"title":"","type":"data","query":"data record( nombre=\"Logout\" )","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-13-default, #1c520a)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AccountIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"28":{"title":"","type":"data","query":"data record( nombre=\"Updates\" )","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-loglevel-severe-default, #d56b1a)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"CompareIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"29":{"title":"","type":"data","query":"data record( nombre=\"Create\" )","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-07-default, #438fb1)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"RepairIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"30":{"title":"","type":"data","query":"data record( nombre=\"Delete\" )","visualization":"singleValue","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-loglevel-emergency-default, #ae132d)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"DeclineIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"}},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"31":{"title":"","type":"data","query":"data record( nombre=\"General\" )","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-08-default, #8b6ecf)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"32":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"user","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["user"],"valueAxis":["count"],"isCategoryLabelVisible":true,"isValueLabelVisible":false},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"position":"auto","hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"33":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['eventType', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"position":"auto","hidden":false}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"34":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"35":{"title":"","type":"data","query":"data record( nombre= concat(\"Per EventType / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-02-default, #2c2f3f)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"36":{"title":"","type":"data","query":"data record( nombre= concat(\"Per Domain / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-02-default, #2c2f3f)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"37":{"title":"","type":"data","query":"data record( nombre= concat(\"Per User / \",$Time))\n","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-02-default, #2c2f3f)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"38":{"title":"","type":"data","query":"data record( nombre= concat(\"Per Category / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-02-default, #2c2f3f)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"39":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['category', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"41":{"title":"","type":"data","query":"data record( nombre= concat(\"Per UserOrigin / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-02-default, #2c2f3f)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"42":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['userOrigin', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"43":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['userOrigin' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"userOrigin","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["userOrigin"],"valueAxis":["count"],"isCategoryLabelVisible":true,"isValueLabelVisible":false},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"position":"auto","hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"44":{"title":"","type":"data","query":"data record( nombre= concat(\"Per EntityID / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-02-default, #2c2f3f)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"45":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['entityId','eventType', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"47":{"title":"","type":"data","query":"data record( nombre= concat(\"Per UserType / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-02-default, #2c2f3f)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"49":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['userType','eventType', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"50":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"DELETE\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"51":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"DELETE\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"user","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["user"],"valueAxis":["count"],"isCategoryLabelVisible":true,"isValueLabelVisible":false},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"position":"auto","hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"52":{"title":"","type":"data","query":"data record( nombre= concat(\"Deletes Per User / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-security-risk-level-high-default, #cd3741)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"53":{"title":"","type":"data","query":"data record( nombre= concat(\"Updates Per User / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-loglevel-severe-default, #d56b1a)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"54":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"UPDATE\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user',  'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"55":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"UPDATE\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"user","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["user"],"valueAxis":["count"],"isCategoryLabelVisible":true,"isValueLabelVisible":false},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"position":"auto","hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"56":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = {\n      filter,\n      from,\n      to,\n      pageSize\n    };\n\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  let filterVar = [];\n\n  // Filtrar usuario\n  if ($User) {\n    const userArray = Array.isArray($User) ? $User : [$User];\n    if (userArray.length <= 5) {\n      filterVar.push(`user(\"${userArray.join('\", \"')}\")`);\n    } else {\n      console.log(`Más de 5 usuarios, se omite el filtro`);\n    }\n  }\n\n  // Filtrar eventType\n  if ($EventType) {\n    const eventTypeArray = Array.isArray($EventType) ? $EventType : [$EventType];\n    if (eventTypeArray.length <= 5) {\n      filterVar.push(`eventType(\"${eventTypeArray.join('\", \"')}\")`);\n    } else {\n      console.log(`Más de 5 eventTypes, se omite el filtro`);\n    }\n  }\n\n  // Filtrar category\n  if ($Category) {\n    const categoryArray = Array.isArray($Category) ? $Category : [$Category];\n    if (categoryArray.length <= 5) {\n      filterVar.push(`category(\"${categoryArray.join('\", \"')}\")`);\n    } else {\n      console.log(`Más de 5 categorías, se omite el filtro`);\n    }\n  }\n\n  // Filtrar entityId\n  if ($EntityId) {\n    const entityIdArray = Array.isArray($EntityId) ? $EntityId : [$EntityId];\n    if (entityIdArray.length <= 5) {\n      filterVar.push(`entityId(\"${entityIdArray.join('\", \"')}\")`);\n    } else {\n      console.log(`Más de 5 entityIds, se omite el filtro`);\n    }\n  }\n\n\n\n  // Concatenamos todos los filtros aplicados\n  const finalFilter = filterVar.length > 0 ? filterVar.join(' , ') : '';\n\n  // Realizamos la solicitud de los logs con los filtros generados\n  const data = await fetchAllAuditLogs({\n    filter: finalFilter,\n    from: $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 1000\n  });\n\n  const types = [{\n    mappings: {\n      Total: { type: 'integer' }\n    },\n    indexRange: [0, data.length]\n  }];\n\n  const dataFrame = {\n    records: [],\n    types: types\n  };\n\n  const total = data.length;\n  const record = { Total: total };\n\n  dataFrame.records.push(record);\n  console.log(dataFrame);\n\n  return data;\n}\n","visualization":"table","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"Total","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"}}},"57":{"title":"","type":"data","query":"data record( nombre=\"LogAudit\" )","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-themed-fireplace-color-06-default, #9033a3)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AbcIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"58":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['category'],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"category","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["category"],"valueAxis":["count"]},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"59":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['userType' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"entityId","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["entityId"],"valueAxis":["count"]},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"60":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: '', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['entityId' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"autoSelectVisualization":false,"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"entityId","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["entityId"],"valueAxis":["count"]},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"61":{"title":"","type":"data","query":"data record( nombre= concat(\"Logins Per User / \",$Time))","visualization":"singleValue","visualizationSettings":{"thresholds":[{"id":1,"field":"nombre","title":"","isEnabled":true,"rules":[{"id":0,"color":{"Default":"var(--dt-colors-charts-categorical-color-13-default, #1c520a)"},"comparator":"!=","label":"","value":"0"},{"id":1,"color":{"Default":"var(--dt-colors-charts-status-warning-default, #eca440)"},"comparator":"≥","label":""},{"id":2,"color":{"Default":"var(--dt-colors-charts-status-critical-default, #c4233b)"},"comparator":"≥","label":""}]}],"chartSettings":{"gapPolicy":"gap","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"middle"},"singleValue":{"showLabel":false,"label":"a","prefixIcon":"AnalyticsIcon","isIconVisible":true,"recordField":"nombre","autoscale":true,"sparklineSettings":{},"alignment":"start","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"background"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{},"displayedFields":[],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"categorical"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[],"variant":"single","truncationMode":"middle"},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false},"querySettings":{"maxResultRecords":1000,"defaultScanLimitGbytes":500,"maxResultMegaBytes":1,"defaultSamplingRatio":10,"enableSampling":false},"davis":{"enabled":false,"davisVisualization":{"isAvailable":true}}},"62":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n            // value = value.split('@')[1]; // solo el dominio\n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"LOGIN\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user', 'timestamp' ],\n    { timeGranularity: $Time } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"lineChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"eventType","valueAxisLabel":"count","tooltipVariant":"single"},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","fieldMapping":{"timestamp":"timestamp","leftAxisValues":["count"]},"xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}},"63":{"title":"","type":"code","input":"import { auditLogsClient } from '@dynatrace-sdk/client-classic-environment-v2';\n\nexport default async function () {\n  // 👉 Normaliza timestamp según granularidad (day, hour, minute)\n  function normalizeToGranularity(value, granularity = 'minute') {\n    if (!value) return 'UNKNOWN';\n\n    const date = typeof value === 'number' ? new Date(value) : new Date(value);\n    if (isNaN(date.getTime())) return 'UNKNOWN';\n\n    const year = date.getUTCFullYear();\n    const month = String(date.getUTCMonth() + 1).padStart(2, '0');\n    const day = String(date.getUTCDate()).padStart(2, '0');\n    const hour = String(date.getUTCHours()).padStart(2, '0');\n    const minute = String(date.getUTCMinutes()).padStart(2, '0');\n\n    switch (granularity) {\n      case 'day':\n        return `${year}-${month}-${day}T00:00`;\n      case 'hour':\n        return `${year}-${month}-${day}T${hour}:00`;\n      case 'minute':\n      default:\n        return `${year}-${month}-${day}T${hour}:${minute}`;\n    }\n  }\n\n  // 👉 Inferencia de tipo\n  function inferType(value) {\n    if (typeof value === 'number') return 'long';\n    if (!isNaN(Date.parse(value))) return 'timestamp';\n    return 'string';\n  }\n\n  // 🔁 Agrupación flexible\n  function buildDataFrameAdvanced(data, groupByFields = [], { timeGranularity = 'minute' } = {}) {\n    const grouped = {};\n    const hasNoSystem = groupByFields.includes('no-system');\n\n    const filteredData = hasNoSystem\n      ? data.filter(item => typeof item.user === 'string' && item.user.includes('@'))\n      : data;\n\n    filteredData.forEach(item => {\n      const keyParts = groupByFields\n        .filter(field => field !== 'no-system') // Ignorar 'no-system' como campo real\n        .map(field => {\n          let value = item[field] ?? 'UNKNOWN';\n\n          if (field === 'timestamp') {\n            value = normalizeToGranularity(value, timeGranularity);\n          } else if (field === 'user' && typeof value === 'string' && value.includes('@')) {\n            value = value \n          }\n\n          return value;\n        });\n\n      const key = keyParts.join('|');\n      grouped[key] = (grouped[key] || 0) + 1;\n    });\n\n    const records = Object.entries(grouped)\n      .sort(([, a], [, b]) => b - a)\n      .map(([key, count]) => {\n        const values = key.split('|');\n        const record = {};\n        groupByFields\n          .filter(field => field !== 'no-system')\n          .forEach((field, i) => {\n            record[field] = values[i];\n          });\n        record.count = count;\n        return record;\n      });\n\n    const sample = records[0] || {};\n    const mappings = groupByFields\n      .filter(field => field !== 'no-system')\n      .reduce((acc, field) => {\n        acc[field] = { type: inferType(sample[field]) };\n        return acc;\n      }, { count: { type: 'long' } });\n\n    const types = [{\n      mappings,\n      indexRange: [0, records.length]\n    }];\n\n    return { records, types };\n  }\n\n  // 📥 Fetch paginado de logs\n  async function fetchAllAuditLogs({ filter, from, to, pageSize } = {}) {\n    let auditLogs = [];\n    let next = undefined;\n\n    const config = { filter, from, to, pageSize };\n    console.log(`Fetching first page...`);\n    const firstresponse = await auditLogsClient.getLogs(config);\n    auditLogs = [...firstresponse.auditLogs];\n    next = firstresponse.nextPageKey;\n\n    let pageCounter = 1;\n    while (next) {\n      console.log(`Fetching page ${++pageCounter}...`);\n      const response = await auditLogsClient.getLogs({ nextPageKey: next });\n      auditLogs = [...auditLogs, ...response.auditLogs];\n      next = response.nextPageKey;\n    }\n\n    return auditLogs;\n  }\n\n  // 🧪 Ejecución final\n  const data = await fetchAllAuditLogs({\n    filter: 'eventType(\"LOGIN\")', // eventType(\"LOGIN\")\n    from:  $dt_timeframe_from,\n    to: $dt_timeframe_to,\n    pageSize: 5000\n  });\n\n  // 📊 Agrupar por campos (con granularidad configurable)\n  const groupedData = buildDataFrameAdvanced(\n    data,\n    ['user' ],\n    { timeGranularity: 'day' } // 👈 Podés usar 'minute', 'hour' o 'day'\n  );\n\n  console.log(groupedData);\n  return groupedData;\n}\n","visualization":"categoricalBarChart","visualizationSettings":{"thresholds":[],"chartSettings":{"gapPolicy":"connect","circleChartSettings":{"groupingThresholdType":"relative","groupingThresholdValue":0,"valueType":"relative"},"categoryOverrides":{},"curve":"linear","pointsDisplay":"auto","categoricalBarChartSettings":{"layout":"horizontal","categoryAxisTickLayout":"horizontal","scale":"absolute","groupMode":"stacked","colorPaletteMode":"multi-color","valueAxisScale":"linear","categoryAxisLabel":"user","valueAxisLabel":"count","tooltipVariant":"single","categoryAxis":["user"],"valueAxis":["count"],"isCategoryLabelVisible":true,"isValueLabelVisible":false},"colorPalette":"categorical","valueRepresentation":"absolute","truncationMode":"end","xAxisScaling":"auto","xAxisLabel":"timestamp","xAxisIsLabelVisible":false,"hiddenLegendFields":["count"],"leftYAxisSettings":{"isLabelVisible":false},"tooltip":{"variant":"single","seriesDisplayMode":"single-line"},"legend":{"position":"auto","hidden":true}},"singleValue":{"showLabel":true,"label":"element","prefixIcon":"AnalyticsIcon","isIconVisible":false,"recordField":"element","autoscale":true,"sparklineSettings":{},"alignment":"center","trend":{"trendType":"auto","isVisible":true},"colorThresholdTarget":"value"},"table":{"rowDensity":"condensed","enableSparklines":false,"hiddenColumns":[],"linewrapEnabled":false,"lineWrapIds":[],"monospacedFontEnabled":false,"monospacedFontColumns":[],"columnWidths":{},"columnTypeOverrides":[]},"honeycomb":{"shape":"hexagon","legend":{"hidden":false,"position":"auto","ratio":"auto"},"dataMappings":{"value":"count"},"displayedFields":["user"],"truncationMode":"middle","colorMode":"color-palette","colorPalette":"blue"},"histogram":{"legend":{"position":"auto"},"yAxis":{"label":"Frequency","isLabelVisible":true,"scale":"linear"},"colorPalette":"categorical","dataMappings":[{"valueAxis":"count","rangeAxis":""}],"variant":"single","truncationMode":"middle","displayedFields":["eventType"]},"valueBoundaries":{"min":"auto","max":"auto"},"autoSelectVisualization":false,"dataMapping":{"longitude":"count","displayedFields":["eventType","timestamp"],"dimension":"eventType","value":"count"},"legend":{"textTruncationMode":"middle","showLegend":true,"position":"auto","ratio":24},"tooltip":{"showCustomFields":false},"label":{"showLabel":true,"label":"count"}}}},"layouts":{"9":{"x":0,"y":11,"w":12,"h":5},"17":{"x":12,"y":17,"w":12,"h":6},"18":{"x":0,"y":17,"w":12,"h":6},"19":{"x":0,"y":8,"w":4,"h":2},"20":{"x":4,"y":8,"w":4,"h":2},"21":{"x":8,"y":8,"w":4,"h":2},"22":{"x":12,"y":8,"w":4,"h":2},"23":{"x":16,"y":8,"w":4,"h":2},"24":{"x":20,"y":8,"w":4,"h":2},"26":{"x":0,"y":7,"w":4,"h":1},"27":{"x":4,"y":7,"w":4,"h":1},"28":{"x":8,"y":7,"w":4,"h":1},"29":{"x":12,"y":7,"w":4,"h":1},"30":{"x":16,"y":7,"w":4,"h":1},"31":{"x":20,"y":7,"w":4,"h":1},"32":{"x":0,"y":24,"w":12,"h":5},"33":{"x":12,"y":11,"w":12,"h":5},"34":{"x":12,"y":24,"w":12,"h":5},"35":{"x":0,"y":10,"w":24,"h":1},"36":{"x":0,"y":16,"w":24,"h":1},"37":{"x":0,"y":23,"w":24,"h":1},"38":{"x":0,"y":47,"w":24,"h":1},"39":{"x":12,"y":48,"w":12,"h":5},"41":{"x":0,"y":53,"w":24,"h":1},"42":{"x":12,"y":54,"w":12,"h":5},"43":{"x":0,"y":54,"w":12,"h":5},"44":{"x":0,"y":59,"w":24,"h":1},"45":{"x":12,"y":60,"w":12,"h":5},"47":{"x":0,"y":65,"w":24,"h":1},"49":{"x":12,"y":66,"w":12,"h":5},"50":{"x":12,"y":36,"w":12,"h":5},"51":{"x":1,"y":36,"w":11,"h":5},"52":{"x":1,"y":35,"w":23,"h":1},"53":{"x":1,"y":41,"w":23,"h":1},"54":{"x":12,"y":42,"w":12,"h":5},"55":{"x":1,"y":42,"w":11,"h":5},"56":{"x":0,"y":1,"w":24,"h":6},"57":{"x":0,"y":0,"w":24,"h":1},"58":{"x":0,"y":48,"w":12,"h":5},"59":{"x":0,"y":66,"w":12,"h":5},"60":{"x":0,"y":60,"w":12,"h":5},"61":{"x":1,"y":29,"w":23,"h":1},"62":{"x":12,"y":30,"w":12,"h":5},"63":{"x":1,"y":30,"w":11,"h":5}},"importedWithCode":true,"settings":{}}