graph_reports.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <div class="w-full space-y-6">
  2. <!-- Main metrics cards -->
  3. <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
  4. <div class="bg-white p-4 rounded-lg shadow-sm border border-gray-200">
  5. <h3 class="text-lg font-semibold text-gray-700">
  6. {{ _("Usuarios Totales") }}
  7. </h3>
  8. <p class="text-2xl font-bold text-blue-600">
  9. {{ metrics.total_stats.total_users }}
  10. </p>
  11. <p class="mt-1 text-xs text-gray-500">{{ _("Usuarios únicos con actividad") }}</p>
  12. </div>
  13. <div class="bg-white p-4 rounded-lg shadow-sm border border-gray-200">
  14. <h3 class="text-lg font-semibold text-gray-700">
  15. {{ _("Registros de Log") }}
  16. </h3>
  17. <p class="text-2xl font-bold text-green-600">
  18. {{ metrics.total_stats.total_log_entries }}
  19. </p>
  20. <p class="mt-1 text-xs text-gray-500">{{ _("Eventos registrados") }}</p>
  21. </div>
  22. <div class="bg-white p-4 rounded-lg shadow-sm border border-gray-200">
  23. <h3 class="text-lg font-semibold text-gray-700">
  24. {{ _("Datos Transmitidos") }}
  25. </h3>
  26. <p class="text-2xl font-bold text-purple-600">
  27. {{ "%.2f"|format(metrics.total_stats.total_data_transmitted / (1024**3)) }} {{ _("GB") }}
  28. </p>
  29. <p class="mt-1 text-xs text-gray-500">
  30. {{ _("Promedio:") }} {{ "%.1f"|format(metrics.average_data_per_request / 1024) }} {{ _("KB por petición") }}
  31. </p>
  32. </div>
  33. <div class="bg-white p-4 rounded-lg shadow-sm border border-gray-200">
  34. <h3 class="text-lg font-semibold text-gray-700">{{ _("Total de Peticiones") }}</h3>
  35. <p class="text-2xl font-bold text-orange-600">
  36. {{ metrics.total_stats.total_requests }}
  37. </p>
  38. <p class="mt-1 text-xs text-gray-500">{{ _("Redirecciones:") }} {{ metrics.redirect_requests }}</p>
  39. </div>
  40. </div>
  41. <!-- Health and security metrics -->
  42. <section class="rounded-lg border border-slate-200 bg-slate-50 p-4 sm:p-5">
  43. <div class="mb-4 flex flex-col gap-1 sm:flex-row sm:items-baseline sm:justify-between">
  44. <h2 class="text-xl font-bold text-gray-800">{{ _("Calidad y seguridad del tráfico") }}</h2>
  45. <p class="text-sm text-gray-500">{{ _("Indicadores calculados para la fecha seleccionada") }}</p>
  46. </div>
  47. <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4">
  48. <div class="rounded-lg border border-emerald-100 bg-white p-4 shadow-sm">
  49. <h3 class="text-sm font-semibold text-gray-700">{{ _("Tasa de éxito HTTP") }}</h3>
  50. <p class="text-2xl font-bold text-emerald-600">{{ "%.1f"|format(metrics.successful_request_rate) }}%</p>
  51. <p class="mt-1 text-xs text-gray-500">{{ metrics.success_requests }} {{ _("peticiones 2xx") }}</p>
  52. </div>
  53. <div class="rounded-lg border border-red-100 bg-white p-4 shadow-sm">
  54. <h3 class="text-sm font-semibold text-gray-700">{{ _("Errores HTTP") }}</h3>
  55. <p class="text-2xl font-bold text-red-600">{{ "%.1f"|format(metrics.error_request_rate) }}%</p>
  56. <p class="mt-1 text-xs text-gray-500">
  57. {{ metrics.error_requests }} · {{ metrics.client_error_requests }} 4xx / {{ metrics.server_error_requests }} 5xx
  58. </p>
  59. </div>
  60. <div class="rounded-lg border border-amber-100 bg-white p-4 shadow-sm">
  61. <h3 class="text-sm font-semibold text-gray-700">{{ _("Accesos bloqueados") }}</h3>
  62. <p class="text-2xl font-bold text-amber-600">{{ metrics.blocked_requests }}</p>
  63. <p class="mt-1 text-xs text-gray-500">
  64. {{ "%.1f"|format(metrics.blocked_request_rate) }}% · {{ metrics.blocked_users }} {{ _("Usuarios afectados") }} / {{ metrics.blocked_ips }} IPs
  65. </p>
  66. </div>
  67. <div class="rounded-lg border border-indigo-100 bg-white p-4 shadow-sm">
  68. <h3 class="text-sm font-semibold text-gray-700">{{ _("Destinos únicos") }}</h3>
  69. <p class="text-2xl font-bold text-indigo-600">{{ metrics.unique_domains }}</p>
  70. <p class="mt-1 text-xs text-gray-500">
  71. {% if metrics.total_stats.total_requests %}
  72. {{ _("Hora pico:") }} {{ "%02d:00"|format(metrics.peak_hour.hour) }}
  73. {% else %}
  74. {{ _("Sin actividad") }}
  75. {% endif %}
  76. </p>
  77. </div>
  78. </div>
  79. </section>
  80. <!-- Main charts -->
  81. <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
  82. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  83. <h2 class="text-xl font-bold mb-4 text-gray-800">
  84. {{ _("Top 20 Usuarios por Actividad") }}
  85. </h2>
  86. <div class="h-80">
  87. <canvas id="usersActivityChart"></canvas>
  88. </div>
  89. </div>
  90. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  91. <h2 class="text-xl font-bold mb-4 text-gray-800">
  92. {{ _("Top 20 Usuarios por Datos Transmitidos") }}
  93. </h2>
  94. <div class="h-80">
  95. <canvas id="usersDataChart"></canvas>
  96. </div>
  97. </div>
  98. </div>
  99. <!-- Traffic trend -->
  100. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  101. <div class="mb-4 flex flex-col gap-1 sm:flex-row sm:items-baseline sm:justify-between">
  102. <h2 class="text-xl font-bold text-gray-800">{{ _("Actividad por hora") }}</h2>
  103. <p class="text-sm text-gray-500">{{ _("Peticiones y datos transferidos durante la fecha seleccionada") }}</p>
  104. </div>
  105. <div class="h-80">
  106. <canvas id="hourlyActivityChart"></canvas>
  107. </div>
  108. </div>
  109. <!-- HTTP codes + destination TLD charts -->
  110. <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
  111. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  112. <h2 class="text-xl font-bold mb-4 text-gray-800">
  113. {{ _("Distribución de Códigos HTTP") }}
  114. </h2>
  115. <div class="h-96">
  116. <canvas id="httpCodesChart"></canvas>
  117. </div>
  118. </div>
  119. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  120. <div class="flex items-start justify-between gap-4 mb-4">
  121. <div>
  122. <h2 class="text-xl font-bold text-gray-800">
  123. {{ _("Destinos por TLD") }}
  124. </h2>
  125. <p class="mt-1 text-sm text-gray-500">
  126. {{ _("Estimado a partir del dominio de destino; no es geolocalización.") }}
  127. </p>
  128. </div>
  129. </div>
  130. <div class="h-96">
  131. <canvas id="countriesChart"></canvas>
  132. </div>
  133. </div>
  134. </div>
  135. <!-- Most visited pages table -->
  136. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  137. <h2 class="text-xl font-bold mb-4 text-gray-800">
  138. {{ _("Top 20 Páginas Más Visitadas") }}
  139. </h2>
  140. <div class="overflow-x-auto">
  141. <table class="min-w-full divide-y divide-gray-200">
  142. <thead class="bg-gray-50">
  143. <tr>
  144. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  145. {{ _("URL") }}
  146. </th>
  147. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  148. {{ _("Total de Peticiones") }}
  149. </th>
  150. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  151. {{ _("Usuarios únicos") }}
  152. </th>
  153. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  154. {{ _("Datos Transmitidos") }}
  155. </th>
  156. </tr>
  157. </thead>
  158. <tbody class="bg-white divide-y divide-gray-200">
  159. {% for page in metrics.top_pages %}
  160. <tr class="hover:bg-gray-50">
  161. <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 truncate max-w-xs">
  162. {{ page.url }}
  163. </td>
  164. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
  165. {{ page.total_requests }}
  166. </td>
  167. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
  168. {{ page.unique_visits }}
  169. </td>
  170. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
  171. {{ "%.2f"|format(page.total_data_bytes / (1024**2)) }} {{ _("MB") }}
  172. </td>
  173. </tr>
  174. {% else %}
  175. <tr>
  176. <td colspan="4" class="px-6 py-4 text-center text-sm text-gray-500">
  177. {{ _("No hay actividad para esta fecha.") }}
  178. </td>
  179. </tr>
  180. {% endfor %}
  181. </tbody>
  182. </table>
  183. </div>
  184. </div>
  185. <!-- Destination and high-consumption rankings -->
  186. <div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
  187. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  188. <h2 class="text-xl font-bold mb-4 text-gray-800">
  189. {{ _("Top dominios de destino") }}
  190. </h2>
  191. <div class="overflow-x-auto">
  192. <table class="min-w-full divide-y divide-gray-200">
  193. <thead class="bg-gray-50">
  194. <tr>
  195. <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  196. {{ _("Dominio") }}
  197. </th>
  198. <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  199. {{ _("Peticiones") }}
  200. </th>
  201. <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  202. {{ _("Datos Transmitidos") }}
  203. </th>
  204. </tr>
  205. </thead>
  206. <tbody class="bg-white divide-y divide-gray-200">
  207. {% for domain in metrics.top_domains %}
  208. <tr class="hover:bg-gray-50">
  209. <td class="px-4 py-3 whitespace-nowrap text-sm font-medium text-gray-900 truncate max-w-xs">
  210. {{ domain.domain }}
  211. </td>
  212. <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">
  213. {{ domain.total_requests }}
  214. </td>
  215. <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">
  216. {{ "%.2f"|format(domain.total_data_bytes / (1024**2)) }} {{ _("MB") }}
  217. </td>
  218. </tr>
  219. {% else %}
  220. <tr>
  221. <td colspan="3" class="px-4 py-4 text-center text-sm text-gray-500">
  222. {{ _("No hay destinos identificables para esta fecha.") }}
  223. </td>
  224. </tr>
  225. {% endfor %}
  226. </tbody>
  227. </table>
  228. </div>
  229. </div>
  230. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  231. <h2 class="text-xl font-bold mb-4 text-gray-800">
  232. {{ _("URLs con mayor consumo de datos") }}
  233. </h2>
  234. <div class="overflow-x-auto">
  235. <table class="min-w-full divide-y divide-gray-200">
  236. <thead class="bg-gray-50">
  237. <tr>
  238. <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  239. {{ _("URL") }}
  240. </th>
  241. <th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  242. {{ _("Datos Transmitidos") }}
  243. </th>
  244. </tr>
  245. </thead>
  246. <tbody class="bg-white divide-y divide-gray-200">
  247. {% for page in metrics.top_pages_by_data %}
  248. <tr class="hover:bg-gray-50">
  249. <td class="px-4 py-3 whitespace-nowrap text-sm font-medium text-gray-900 truncate max-w-xs">
  250. {{ page.url }}
  251. </td>
  252. <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">
  253. {{ "%.2f"|format(page.total_data_bytes / (1024**2)) }} {{ _("MB") }}
  254. </td>
  255. </tr>
  256. {% else %}
  257. <tr>
  258. <td colspan="2" class="px-4 py-4 text-center text-sm text-gray-500">
  259. {{ _("No hay actividad para esta fecha.") }}
  260. </td>
  261. </tr>
  262. {% endfor %}
  263. </tbody>
  264. </table>
  265. </div>
  266. </div>
  267. </div>
  268. <!-- Shared IPs table -->
  269. <div class="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
  270. <h2 class="text-xl font-bold mb-4 text-gray-800">
  271. {{ _("IPs Compartidas por Múltiples Usuarios") }}
  272. </h2>
  273. <div class="overflow-x-auto">
  274. <table class="min-w-full divide-y divide-gray-200">
  275. <thead class="bg-gray-50">
  276. <tr>
  277. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  278. {{ _("IP") }}
  279. </th>
  280. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  281. {{ _("Número de Usuarios") }}
  282. </th>
  283. <th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
  284. {{ _("Usuarios") }}
  285. </th>
  286. </tr>
  287. </thead>
  288. <tbody class="bg-white divide-y divide-gray-200">
  289. {% for ip in metrics.users_per_ip %}
  290. <tr class="hover:bg-gray-50">
  291. <td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
  292. {{ ip.ip }}
  293. </td>
  294. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
  295. {{ ip.user_count }}
  296. </td>
  297. <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
  298. {{ ip.usernames }}
  299. </td>
  300. </tr>
  301. {% else %}
  302. <tr>
  303. <td colspan="3" class="px-6 py-4 text-center text-sm text-gray-500">
  304. {{ _("No se detectaron IPs compartidas.") }}
  305. </td>
  306. </tr>
  307. {% endfor %}
  308. </tbody>
  309. </table>
  310. </div>
  311. </div>
  312. </div>