Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

feat: added ui page to connect to other observability platforms to export data (#129)

Aman Agarwaldd55efad21b4
diff --git a/src/client/public/images/connections/datadog.svg b/src/client/public/images/connections/datadog.svg
new file mode 100644
index 00000000..ac299edb
--- /dev/null
+++ b/src/client/public/images/connections/datadog.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" xmlns:v="https://vecta.io/nano" viewBox="0 0 64 64"><g fill="#5c2d90"><path d="M57.705 33.717l1.575 20.1L31.4 58.82 29 38.72l3.983-.556c.648.278 1.112.37 1.853.556 1.204.278 2.594.648 4.63-.463.463-.278 1.482-1.112 1.853-1.667zm-43.073 23.9c-.463-.74-1.297-1.575-2.594-2.594-1.853-1.482-1.204-4.076-.093-5.65 1.4-2.686 8.707-6.206 8.337-10.56-.185-1.575-.37-3.613-1.853-5.095-.093.556 0 1.112 0 1.112s-.648-.74-.926-1.853c-.278-.37-.556-.556-.834-1.112-.185.648-.185 1.297-.185 1.297s-.463-1.204-.556-2.13c-.278.463-.37 1.297-.37 1.297s-.648-1.853-.463-2.87c-.278-.834-1.204-2.594-.926-6.484 1.575 1.112 5.095.834 6.484-1.204.463-.648.74-2.5-.185-6.114-.648-2.316-2.223-5.743-2.87-7.04l-.093.093c.37 1.02 1.02 3.242 1.297 4.354.74 3.242 1.02 4.354.648 5.836-.278 1.297-1.02 2.13-2.964 3.057-1.853.926-4.446-1.4-4.54-1.482-1.853-1.482-3.242-3.9-3.427-5.002-.185-1.297.74-2.038 1.204-3.057-.648.185-1.4.556-1.4.556s.834-.926 1.945-1.667a9.43 9.43 0 0 0 1.204-.834H10.28s1.112-.648 2.316-1.02H10.93l4.446-1.945c1.4-.556 2.686-.37 3.427.648 1.02 1.4 2.038 2.13 4.168 2.686 1.297-.556 1.76-.926 3.427-1.4 1.482-1.667 2.686-1.853 2.686-1.853s-.834.74-.926 1.575c.834-.648 1.76-1.204 1.76-1.204s-.37.463-.648 1.112l.093.093c1.02-.556 2.13-1.02 2.13-1.02s-.37.37-.74.926c.74 0 2.223 0 2.78.093 3.427.093 4.168-3.613 5.465-4.168 1.667-.556 2.408-.926 5.187 1.853 2.408 2.408 4.26 6.577 3.335 7.503-.74.74-2.316-.278-4.076-2.408-.926-1.112-1.575-2.5-1.945-4.168-.185-1.4-1.204-2.223-1.204-2.223s.648 1.4.648 2.594c0 .648.093 3.057 1.112 4.446-.093.185-.185 1.02-.278 1.112-1.204-1.482-3.9-2.5-4.26-2.87 1.482 1.204 4.817 3.9 6.114 6.484 1.204 2.5.463 4.724 1.112 5.28.185.185 2.594 3.15 3.057 4.724.834 2.686.093 5.465-1.02 7.132l-2.964.463a3.92 3.92 0 0 1-1.112-.371c.185-.37.648-1.297.648-1.482l-.185-.278c-.926 1.297-2.5 2.594-3.798 3.335-1.667.926-3.613.834-4.9.37-3.613-1.112-7.04-3.52-7.78-4.168 0 0 0 .463.093.648a28.07 28.07 0 0 0 5.002 4.168l-4.26.463 2.038 15.747c-.926.093-1.02.185-2.038.37-.834-3.057-2.5-5.002-4.354-6.206-1.575-1.02-3.798-1.297-5.928-.834l-.093.185c1.482-.185 3.242.093 5.002 1.204s3.15 3.983 3.705 5.65c.648 2.223 1.112 4.54-.648 7.04-1.297 1.76-5.002 2.78-7.966.648.834 1.297 1.853 2.316 3.335 2.5 2.13.278 4.168-.093 5.65-1.482 1.204-1.204 1.853-3.798 1.667-6.577l1.945-.278.648 4.9L62.06 56.7l-2.78-25.195-1.575.278L54.556 0 1.942 6.114l6.484 52.428z" mask="url(#A)"/><path d="M39.665 30.06c1.4 1.02 2.594 1.667 3.798 1.575.74-.093 1.482-1.297 1.945-2.408.37-.74.37-1.575-.185-1.853-.278-.093-1.4-.093-2.223 0-1.575.185-3.15.74-3.52 1.02-.556.37-.278 1.297.185 1.667m.37-10.84v.093l.093.185c.37.74.74 1.482 1.482 1.853.185 0 .37-.093.556-.093.648 0 1.02.093 1.297.185v-.556c-.093-.926.185-2.594-1.667-3.52-.74-.37-1.667-.185-2.038.185h.185c.463.185.185.37.093.556-.093.37-.185.463 0 1.112"/><path d="M31.698 19.407c.463-.37-2.13-.926-4.168.37-1.482 1.02-1.482 3.15-.093 4.354a1.27 1.27 0 0 1 .37.278c.37-.185.926-.37 1.4-.556.926-.278 1.667-.463 2.316-.556.278-.37.648-.926.556-1.945-.093-1.4-1.204-1.112-.37-1.945m15.098 22.5l-4.446 7.4-5.187-1.575-4.54 6.947.185 2.223 24.825-4.54-1.482-15.47-4.076 8.522z"/></g></svg>
\ No newline at end of file
diff --git a/src/client/public/images/connections/dynatrace.svg b/src/client/public/images/connections/dynatrace.svg
new file mode 100644
index 00000000..09f9d8c4
--- /dev/null
+++ b/src/client/public/images/connections/dynatrace.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 51200 9088" width="64" height="64" xmlns:v="https://vecta.io/nano"><path d="M17374.69-16768.765c-658.026 3472.92-1462.28 8627.467-1900.97 13855.13-767.7 9212.38-292.45 15390.52-292.45 15390.52L2203.514 24796.61s-987.04-6909.283-1498.838-14695.935C412.225 5275.144 302.548 1034.526 302.548-1524.47c0-146.226 73.113-292.458 73.113-438.684 0-182.782 219.338-1900.97 1900.97-3509.48 1827.842-1754.73 15317.397-12319.725 15098.06-11296.13" fill="#3a8aca"/><path d="M17374.69-16768.765c-658.026 3472.92-1462.28 8627.467-1900.97 13855.13 0 0-14366.927-1718.187-15171.182 1754.744 0-182.782 255.895-2303.1 1937.562-3911.608 1827.816-1754.744 15353.928-12721.86 15134.6-11698.266" fill="#262424"/><path d="M302.537-1999.7v804.255c146.226-621.47 402.128-1060.154 913.928-1754.736 1060.154-1352.612 2778.337-1718.187 3472.92-1791.3 3509.48-475.244 8700.58-1023.597 13928.243-1169.827 9248.936-292.45 15353.964 475.24 15353.964 475.24l12977.755-12319.725s-6799.614-1279.496-14549.71-2193.384c-5081.43-621.47-9541.39-950.485-12063.83-1096.714-182.782 0-1974.082-219.338-3655.705 1389.17L1837.935-5545.743C156.312-3937.232 302.537-2145.936 302.537-1999.7" fill="#c8d643"/><path d="M46474.103 13756.386c-3509.48 475.24-8700.583 1060.154-13928.243 1242.94-9248.936 292.45-15390.524-475.24-15390.524-475.24L4177.58 26880.366s6872.727 1352.612 14622.825 2229.977c4752.416 548.357 8956.478 840.812 11515.473 987.04 182.782 0 475.24-146.226 658.026-146.226s1974.082-329.015 3655.705-1937.562c1827.856-1754.736 12868.085-14366.92 11844.492-14257.25" fill="#63308c"/><path d="M46474.107 13756.386c-3509.476 475.24-8700.58 1060.154-13928.243 1242.94 0 0 987.04 14440.04-2485.88 15061.51 182.782 0 2558.995-109.67 4240.615-1718.187 1827.856-1754.744 13197.1-14695.938 12173.5-14586.27" fill="#262424"/><path d="M30827.68 30133.947c-255.895 0-511.797-36.556-804.255-36.556 658.03-109.67 1096.714-329.015 1791.3-840.812 1389.17-987.04 1827.856-2705.224 1974.082-3399.807 621.47-3472.92 1462.28-8627.467 1864.413-13855.13 731.143-9212.38 292.458-15353.964 292.458-15353.964l12977.755-12356.29s950.485 6872.73 1498.838 14659.382c329.015 5081.43 438.684 9577.95 475.24 12063.83 0 182.782 146.226 1974.082-1535.394 3582.593L34556.51 28744.81c-1754.744 1608.51-3546.036 1389.17-3728.825 1389.17" fill="#81b950"/></svg>
\ No newline at end of file
diff --git a/src/client/public/images/connections/grafana.svg b/src/client/public/images/connections/grafana.svg
new file mode 100644
index 00000000..e252626a
--- /dev/null
+++ b/src/client/public/images/connections/grafana.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64" xmlns:v="https://vecta.io/nano" viewBox="0 0 64 64"><defs><clipPath ><use xlink:href="#E"/></clipPath><clipPath id="B"><use xlink:href="#F"/></clipPath><linearGradient gradientTransform="matrix(0,-255.7742,-255.7742,0,2099115.5,-207133.55)" y2="8201.71" x2="-812.649" y1="8201.71" x1="-819.765" gradientUnits="userSpaceOnUse" id="C"><stop offset="0" stop-color="#fff200"/><stop offset="1" stop-color="#f15a29"/></linearGradient><clipPath ><use xlink:href="#O" href="#E"/></clipPath><path id="E" d="M-849.7-1412.2h4355.2V4224H-849.7z"/><path d="M1229.6 328.6l-1.6 7.8-24.9 7.4c-11.5 3.5-22.8 7.7-34.3 11.8-11.3 4.4-22.8 8.8-34 13.8-22.6 9.7-45 20.6-66.9 32.9-21.2 11.9-42.1 25-62.4 39.2-2.9-1.4-5.2-2.4-5.2-2.4-207.3-79.2-391.4 16.1-391.4 16.1-16.8 220.5 82.8 359.5 102.5 384.7-4.9 13.6-9.5 27.4-13.7 41.3-15.3 50-26.8 101.3-33.9 154.3l-2.8 23C469.5 1153.1 412.7 1347 412.7 1347 572.6 1530.9 759 1542.3 759 1542.3c.2-.1.3-.3.5-.4 23.7 42.3 51.1 82.6 82 120.1 12.9 15.7 26.5 30.9 40.6 45.6-58.3 166.7 8.2 305.4 8.2 305.4 178 6.7 294.9-77.9 319.5-97.4 17.7 6 35.7 11.3 53.8 16 54.7 14.1 110.7 22.4 166.7 24.8 14 .6 28 .9 41.9.8h6.8l4.4-.1 8.8-.3 8.7-.4.2.3c83.8 119.6 231.3 136.5 231.3 136.5 104.9-110.6 110.9-220.3 110.9-244h0v-1.6c0-2-.1-3.3-.1-3.3-.1-1.7-.1-3.3-.3-5.1 22-15.4 43-32 62.9-49.8a653.67 653.67 0 0 0 109.1-127.9c2.9-4.4 5.7-8.8 8.4-13.3 118.7 6.8 202.4-73.5 202.4-73.5-19.7-123.7-90.2-184-104.9-195.4h0s-.6-.5-1.5-1.1c-.8-.6-1.4-1-1.4-1-.7-.5-1.6-1.1-2.6-1.7l1.8-22.3c.9-13.3 1.2-26.7 1.3-39.9l-.1-9.9-.1-5v-2.5c0-3.4-.1-2.1-.1-3.4l-.4-8.3-.6-11.2c-.2-3.9-.5-7.2-.8-10.7l-1-10.3-1.2-10.3-1.4-10.2c-2-13.6-4.6-27.1-7.7-40.4-12.4-53.3-33.2-103.9-60.7-149.4s-61.7-85.8-100.2-119.7c-38.5-34-81.7-61.3-127-81.7a493.4 493.4 0 0 0-140.3-39.5c-23.7-3.1-47.3-4.3-70.7-4l-8.7.2-2.2.1c-.6 0-3.3.1-3 .1l-3.6.2-8.7.6c-3.3.2-6.7.5-9.6.8-12 1.2-23.9 2.8-35.7 5-47 8.8-91.4 25.8-130.5 49.2s-73.1 52.7-100.8 85.9c-27.6 33.1-49.1 69.8-63.9 107.8s-23.1 77.2-25.4 115.3a337.33 337.33 0 0 0-.6 28.4c0 2.3.1 4.7.2 7l.3 7.6c.3 4.6.7 9.1 1.1 13.6 1.9 19.3 5.4 37.8 10.6 55.7 10.3 35.7 26.9 68 47.3 95.4 20.4 27.5 44.8 50.2 70.7 67.9a289.44 289.44 0 0 0 81 38.5c27.5 8.1 54.8 11.6 80.5 11.5 3.2 0 6.4-.1 9.6-.2 1.7 0 3.4-.2 5.1-.2l5.1-.3 8.2-.8c.6 0 1.5-.2 2.3-.3l2.5-.3c1.7-.2 3.3-.5 5-.7 3.4-.4 6.3-1.1 9.3-1.6 3-.6 6-1.2 9-2 5.9-1.3 11.6-3.1 17.3-4.8 11.2-3.7 21.7-8.2 31.5-13.2s18.8-10.7 27.2-16.6c2.4-1.7 4.7-3.5 7-5.3 9-7 10.4-20.2 3.2-29-6.3-7.7-17.1-9.7-25.7-4.9-2.1 1.2-4.3 2.3-6.5 3.4-7.5 3.6-15.3 7-23.6 9.7-8.3 2.6-16.9 4.8-25.9 6.4-4.5.6-9 1.3-13.6 1.7-2.3.3-4.6.4-7 .4-2.3.1-4.8.3-6.9.2-2.2 0-4.4-.1-6.7-.1l-8.4-.4s-1.4 0-.3-.1l-.9-.1-1.9-.2c-1.3-.1-2.5-.2-3.8-.4l-7.5-1c-20.1-2.8-40.5-8.7-60.1-17.6-19.7-8.9-38.5-21.1-55.5-36.4-17-15.2-31.8-33.6-43.4-54.4-11.6-20.7-19.7-43.8-23.5-68-1.9-12.1-2.7-24.6-2.4-36.8l.5-10.1c0 .9.1-.5.1-.6l.1-1.2.2-2.5c.1-1.7.3-3.3.5-5 .7-6.6 1.7-13.3 2.9-19.8 9.3-52.7 35.7-104.1 76.5-143.2 10.2-9.7 21.2-18.8 32.9-26.8s24.2-15.2 37.2-21.2 26.6-10.9 40.5-14.7c13.9-3.7 28.2-6.2 42.7-7.5a263 263 0 0 1 21.8-.9c1.9 0 3.4.1 4.9.1l5.9.2 3.7.1c1.5 0 0 0 .7.1l1.5.1 5.9.4c15.7 1.3 31.4 3.5 46.8 7 30.9 6.9 60.9 18.2 88.9 33.7 56 31 103.7 79.5 133 138 14.8 29.1 25 60.5 30.2 92.9 1.2 8.1 2.2 16.3 2.9 24.5l.5 6.2.3 6.2c.1 2.1.1 4.1.2 6.2 0 2 .1 4.3.1 5.8v5.3l-.1 6-.7 14.5c-.7 8.9-1.4 17.9-2.6 26.8-1.1 8.8-2.6 17.6-4.2 26.4-1.8 8.7-3.6 17.4-5.9 26-4.3 17.3-9.9 34.2-16.4 50.8-13.1 33.2-30.6 64.7-51.7 93.8-42.3 58.1-100 105.6-165.6 135.4-32.8 14.8-67.4 25.7-103 31.6-17.8 3-35.8 4.8-53.8 5.4l-3.3.1h-2.9l-5.8.1h-8.9-4.4c2.5 0-.4 0-.3-.1l-1.8-.1c-9.7-.2-19.3-.7-28.9-1.4-38.5-2.9-76.6-9.7-113.5-20.5-36.9-10.7-72.7-25-106.6-43-67.7-36.2-128.2-85.8-175.6-145.6-23.8-29.8-44.6-61.8-61.8-95.5s-30.7-69-40.7-105.1c-9.9-36.1-16.1-73.1-18.5-110.3l-.4-7-.1-1.7v-1.5l-.1-3.1-.2-6.1-.1-1.5v-2.1-4.3l-.1-8.7v-1.7c0 .3 0 .3 0-.6v-3.4c0-4.5.2-9.1.3-13.6.7-18.4 2.2-37.3 4.6-56.2s5.5-37.9 9.4-56.8c3.9-18.8 8.5-37.5 13.7-55.8 10.5-36.7 23.6-72.3 39.1-105.9 31.1-67.3 71.9-126.6 120.9-174.4 12.2-12 24.9-23.3 38.1-33.9s26.9-20.4 41-29.6c14-9.3 28.5-17.7 43.4-25.5 7.4-4 15-7.5 22.6-11.2l11.5-5.1c3.8-1.7 7.7-3.4 11.6-4.9 15.5-6.6 31.5-12.1 47.5-17.3l12.1-3.7c4-1.3 8.2-2.2 12.2-3.4 8.1-2.3 16.4-4.2 24.6-6.3 4.1-1.1 8.3-1.8 12.4-2.7l12.5-2.6 12.5-2.3 6.3-1.1 6.3-1 12.6-1.9c4.7-.8 9.5-1.2 14.2-1.9l14.1-1.7 8.9-.9 5.9-.6 3-.3 3.5-.2 14.3-.9 7.1-.5s2.6-.1.3-.1l1.5-.1 3-.1 12.2-.6c16.2-.5 32.3-.5 48.2 0 31.9 1.3 63.2 4.8 93.6 10.4 60.9 11.3 118.2 30.9 170 56.5 51.9 25.4 98.4 56.6 138.8 90.5l7.5 6.4 7.3 6.5c4.9 4.3 9.6 8.8 14.3 13.1 4.7 4.4 9.2 8.9 13.8 13.3l13.2 13.5c17.1 18.1 33 36.5 47.3 55 28.7 36.9 51.6 74.1 69.9 109.3 1.2 2.2 2.3 4.4 3.4 6.6l3.2 6.6c2.1 4.3 4.3 8.6 6.2 12.9l5.9 12.7 5.4 12.4c6.8 16.5 13 32.1 18.1 47 8.4 23.9 14.5 45.5 19.3 64.2 1.9 7.5 9 12.5 16.7 11.8 8-.7 14.1-7.3 14.3-15.3.4-20.1-.1-43.8-2.4-70.8-3-33.4-8.7-72.1-20-114.6-11.1-42.5-27.6-89-51.6-137.3-24.1-48.2-55.5-98.4-96.3-146.9-15.9-19-33.3-37.8-52.1-56.1 28-111.4-34.1-208-34.1-208-107.2-6.7-175.4 33.3-200.7 51.6l-12.8-5.4c-18.3-7.4-37-14.3-56.3-20.4s-39-11.7-59.1-16.4c-20.2-4.7-40.7-8.7-61.6-11.9l-11-1.6c-46.6-149.4-180.9-211.9-180.9-211.9-149.8 94.5-178.3 227.4-178.3 227.4" id="F"/></defs><path transform="matrix(.03213 0 0 .03213 -10.727066 -3.251497)" clip-path="url(#B)" d="M412.7 100.8h1834.4v1992.3H412.7z" fill="url(#C)"/></svg>
\ No newline at end of file
diff --git a/src/client/public/images/connections/newrelic.svg b/src/client/public/images/connections/newrelic.svg
new file mode 100644
index 00000000..e2d586bf
--- /dev/null
+++ b/src/client/public/images/connections/newrelic.svg
@@ -0,0 +1 @@
+<svg viewBox="0 0 832.8 959.8" xmlns="http://www.w3.org/2000/svg" width="2169" height="2500"><path d="M672.6 332.3l160.2-92.4v480L416.4 959.8V775.2l256.2-147.6z" fill="#00ac69"/><path d="M416.4 184.6L160.2 332.3 0 239.9 416.4 0l416.4 239.9-160.2 92.4z" fill="#1ce783"/><path d="M256.2 572.3L0 424.6V239.9l416.4 240v479.9l-160.2-92.2z" fill="#1d252c"/></svg>
\ No newline at end of file
diff --git a/src/client/public/images/connections/signoz.svg b/src/client/public/images/connections/signoz.svg
new file mode 100644
index 00000000..7d86bb51
--- /dev/null
+++ b/src/client/public/images/connections/signoz.svg
@@ -0,0 +1,4 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200" fill="none">
+ <path opacity="0.9" d="M100.279 199.833C44.5682 199.833 0 156.12 0 101.479C0 47.3844 44.5682 3.125 100.279 3.125H163.231C183.844 3.125 200 19.5174 200 39.1882V101.479C200 156.12 155.432 199.833 100.279 199.833Z" fill="#F25733"/>
+ <path d="M99.4919 58.9008C57.8802 58.9008 34.4413 93.3585 33.4637 94.8253C31.0537 98.4385 31.0537 103.111 33.4655 106.727C34.4413 108.191 57.8802 142.649 99.4919 142.649C141.103 142.649 164.543 108.191 165.52 106.724C167.93 103.111 167.93 98.4385 165.518 94.8227C164.542 93.3585 141.103 58.9008 99.4919 58.9008ZM39.2234 102.886C38.3677 101.604 38.3677 99.9463 39.2234 98.6633C40.0095 97.4834 56.6976 72.9705 86.5341 67.0904C73.0136 72.3095 63.393 85.4356 63.393 100.775C63.393 116.114 73.0136 129.24 86.5341 134.459C56.6976 128.579 40.0095 104.066 39.2234 102.886ZM82.8568 100.775C82.8568 102.686 81.3074 104.235 79.396 104.235C77.4845 104.235 75.9352 102.686 75.9352 100.775C75.9352 87.7858 86.5024 77.2185 99.4916 77.2185C101.403 77.2185 102.952 78.7676 102.952 80.6792C102.952 82.5908 101.403 84.1398 99.4916 84.1398C90.3189 84.1398 82.8568 91.6019 82.8568 100.775ZM99.4919 109.188C94.8525 109.188 91.0783 105.414 91.0783 100.775C91.0783 96.1356 94.8525 92.3612 99.4919 92.3612C104.132 92.3612 107.906 96.1354 107.906 100.775C107.906 105.414 104.132 109.188 99.4919 109.188ZM159.76 102.886C158.974 104.066 142.286 128.579 112.45 134.459C125.971 129.24 135.591 116.114 135.591 100.775C135.591 85.4358 125.971 72.3096 112.45 67.0905C142.286 72.971 158.974 97.4837 159.76 98.6634C160.616 99.9463 160.616 101.604 159.76 102.886Z" fill="#F9F2F9"/>
+ </svg>
\ No newline at end of file
diff --git a/src/client/src/app/(playground)/connections/add-connections.tsx b/src/client/src/app/(playground)/connections/add-connections.tsx
new file mode 100644
index 00000000..e523d141
--- /dev/null
+++ b/src/client/src/app/(playground)/connections/add-connections.tsx
@@ -0,0 +1,160 @@
+import { FormEventHandler, Fragment, useCallback } from "react";
+import { Dialog, Transition } from "@headlessui/react";
+import { XMarkIcon } from "@heroicons/react/24/outline";
+import { CONNECTIONS, CONNECTIONS_FORM_FIELD } from "./constant";
+import { CONNECTION_PLATFORM_TYPE } from "@/utils/connection";
+import FormBuilder from "@/components/common/form-builder";
+import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
+import toast from "react-hot-toast";
+
+const CONNECTIONS_TOAST_ID = "connection-details";
+
+export default function AddConnections({
+ platform,
+ onClose,
+ onSuccesscb,
+}: {
+ platform: string;
+ onClose: () => void;
+ onSuccesscb: () => void;
+}) {
+ const { fireRequest: firePostRequest, isLoading: isCreating } =
+ useFetchWrapper();
+
+ const onSubmit: FormEventHandler<HTMLFormElement> = useCallback(
+ (event) => {
+ event.preventDefault();
+ const formElement = event.target as HTMLFormElement;
+
+ toast.loading("Adding connection...", {
+ id: CONNECTIONS_TOAST_ID,
+ });
+
+ const formFields =
+ CONNECTIONS_FORM_FIELD[platform as CONNECTION_PLATFORM_TYPE];
+
+ const payload: any = formFields.reduce(
+ (acc: any, item) => {
+ acc[item.name] = (formElement[item.name] as any).value;
+ return acc;
+ },
+ { platform }
+ );
+
+ firePostRequest({
+ body: JSON.stringify(payload),
+ requestType: "POST",
+ url: "/api/connections",
+ responseDataKey: "data",
+ successCb: () => {
+ onSuccesscb();
+ toast.success("Connection added successfully!", {
+ id: CONNECTIONS_TOAST_ID,
+ });
+ },
+ failureCb: (err?: string) => {
+ toast.error(err || "Connection addition failed!", {
+ id: CONNECTIONS_TOAST_ID,
+ });
+ },
+ });
+ },
+ [platform]
+ );
+
+ return (
+ <Transition.Root show as={Fragment}>
+ <Dialog as="div" className="relative z-10" onClose={onClose}>
+ <Transition.Child
+ as={Fragment}
+ enter="ease-in-out duration-500"
+ enterFrom="opacity-0"
+ enterTo="opacity-100"
+ leave="ease-in-out duration-500"
+ leaveFrom="opacity-100"
+ leaveTo="opacity-0"
+ >
+ <div className="fixed inset-0 bg-tertiary/[0.5] bg-opacity-75 transition-opacity" />
+ </Transition.Child>
+
+ <div className="fixed inset-0 overflow-hidden">
+ <div className="absolute inset-0 overflow-hidden">
+ <div className="pointer-events-none fixed inset-y-0 right-0 flex max-w-full pl-10">
+ <Transition.Child
+ as={Fragment}
+ enter="transform transition ease-in-out duration-500 sm:duration-700"
+ enterFrom="translate-x-full"
+ enterTo="translate-x-0"
+ leave="transform transition ease-in-out duration-500 sm:duration-700"
+ leaveFrom="translate-x-0"
+ leaveTo="translate-x-full"
+ >
+ <Dialog.Panel className="pointer-events-auto relative w-screen max-w-2xl">
+ <div className="flex h-full flex-col overflow-y-scroll bg-white shadow-xl">
+ <div className="p-4 bg-secondary relative">
+ <div className="flex flex-col">
+ <Dialog.Title className="flex items-center text-2xl font-bold leading-7 text-tertiary">
+ <img
+ className="w-8 h-8 rounded-l-sm"
+ src={`/images/connections/${
+ CONNECTIONS[platform as CONNECTION_PLATFORM_TYPE]
+ .image
+ }`}
+ alt={
+ CONNECTIONS[platform as CONNECTION_PLATFORM_TYPE]
+ .name
+ }
+ />
+ <p className="ml-4">
+ Export to{" "}
+ {
+ CONNECTIONS[platform as CONNECTION_PLATFORM_TYPE]
+ .name
+ }
+ </p>
+ </Dialog.Title>
+ </div>
+ <Transition.Child
+ as={Fragment}
+ enter="ease-in-out duration-500"
+ enterFrom="opacity-0"
+ enterTo="opacity-100"
+ leave="ease-in-out duration-500"
+ leaveFrom="opacity-100"
+ leaveTo="opacity-0"
+ >
+ <div className="absolute right-0 top-0 flex pr-2 pt-4 sm:pr-4">
+ <button
+ type="button"
+ className="relative rounded-full text-tertiary/[0.7] hover:text-tertiary focus:outline-none"
+ onClick={onClose}
+ >
+ <span className="sr-only">Close panel</span>
+ <XMarkIcon className="h-6 w-6" aria-hidden="true" />
+ </button>
+ </div>
+ </Transition.Child>
+ </div>
+ <div className="relative p-6 flex-1">
+ <FormBuilder
+ fields={
+ CONNECTIONS_FORM_FIELD[
+ platform as keyof typeof CONNECTIONS_FORM_FIELD
+ ]
+ }
+ heading={`Add details to connect to ${platform}`}
+ isLoading={isCreating}
+ onSubmit={onSubmit}
+ submitButtonText={"Save"}
+ />
+ </div>
+ </div>
+ </Dialog.Panel>
+ </Transition.Child>
+ </div>
+ </div>
+ </div>
+ </Dialog>
+ </Transition.Root>
+ );
+}
diff --git a/src/client/src/app/(playground)/connections/constant.tsx b/src/client/src/app/(playground)/connections/constant.tsx
new file mode 100644
index 00000000..c6888ff3
--- /dev/null
+++ b/src/client/src/app/(playground)/connections/constant.tsx
@@ -0,0 +1,83 @@
+import { CONNECTION_PLATFORM } from "@/utils/connection";
+
+export const CONNECTIONS = {
+ grafana: {
+ name: "Grafana",
+ image: "/grafana.svg",
+ platform: CONNECTION_PLATFORM.grafana,
+ },
+ datadog: {
+ name: "Datadog",
+ image: "/datadog.svg",
+ platform: CONNECTION_PLATFORM.datadog,
+ },
+ newrelic: {
+ name: "New Relic",
+ image: "/newrelic.svg",
+ platform: CONNECTION_PLATFORM.newrelic,
+ },
+ signoz: {
+ name: "Signoz",
+ image: "/signoz.svg",
+ platform: CONNECTION_PLATFORM.signoz,
+ },
+ dynatrace: {
+ name: "Dynatrace",
+ image: "/dynatrace.svg",
+ platform: CONNECTION_PLATFORM.dynatrace,
+ },
+};
+
+const commonFormField = [
+ {
+ label: "API key",
+ type: "text",
+ name: "apiKey",
+ placeholder: "Enter Api key",
+ },
+ {
+ label: "Metrics Username",
+ type: "text",
+ name: "metricsUsername",
+ placeholder: "Enter metrics username key",
+ },
+ {
+ label: "Metrics URL",
+ type: "text",
+ name: "metricsUrl",
+ placeholder: "Enter metrics url key",
+ },
+ {
+ label: "Logs Username",
+ type: "text",
+ name: "logsUsername",
+ placeholder: "Enter Logs username key",
+ },
+ {
+ label: "Logs URL",
+ type: "text",
+ name: "logsUrl",
+ placeholder: "Enter Logs url key",
+ },
+];
+
+export const CONNECTIONS_FORM_FIELD = {
+ grafana: commonFormField,
+ datadog: commonFormField,
+ newrelic: commonFormField,
+ dynatrace: commonFormField,
+ signoz: [
+ {
+ label: "API key",
+ type: "text",
+ name: "apiKey",
+ placeholder: "Enter Api key",
+ },
+ {
+ label: "Logs URL",
+ type: "text",
+ name: "logsUrl",
+ placeholder: "Enter Logs url key",
+ },
+ ],
+};
diff --git a/src/client/src/app/(playground)/connections/page.tsx b/src/client/src/app/(playground)/connections/page.tsx
new file mode 100644
index 00000000..9dcd38b3
--- /dev/null
+++ b/src/client/src/app/(playground)/connections/page.tsx
@@ -0,0 +1,187 @@
+"use client";
+import ConfirmationModal from "@/components/common/confirmation-modal";
+import useFetchWrapper from "@/utils/hooks/useFetchWrapper";
+import {
+ MouseEventHandler,
+ useCallback,
+ useEffect,
+ useRef,
+ useState,
+} from "react";
+import toast from "react-hot-toast";
+import { CONNECTIONS } from "./constant";
+import { CheckBadgeIcon, TrashIcon } from "@heroicons/react/24/solid";
+import AddConnections from "./add-connections";
+
+const CONNECTIONS_TOAST_ID = "connection-details";
+
+function ManageConnections() {
+ const { data, fireRequest: fireGetRequest, isLoading } = useFetchWrapper();
+ const { fireRequest: fireDeleteRequest, isLoading: isDeleting } =
+ useFetchWrapper();
+ const [selectedPlatform, setSelectedPlatform] = useState<string | null>(null);
+ const [askConfirmation, setAskConfirmation] = useState<boolean>(false);
+ const [isDeletionConfirm, setIsDeletionConfirm] = useState<boolean>(false);
+
+ const activeConnection = (data as any)?.[0] || {};
+
+ const fetchData = useCallback(() => {
+ fireGetRequest({
+ url: "/api/connections",
+ requestType: "GET",
+ });
+ }, []);
+
+ useEffect(() => {
+ fetchData();
+ }, [fetchData]);
+
+ const handleDelete = useCallback(() => {
+ toast.loading("Deleting Connection!", {
+ id: CONNECTIONS_TOAST_ID,
+ });
+ fireDeleteRequest({
+ url: `/api/connections/${activeConnection.id}`,
+ requestType: "DELETE",
+ successCb: () => {
+ setIsDeletionConfirm(false);
+ fetchData();
+ toast.success("Connection deleted successfully!", {
+ id: CONNECTIONS_TOAST_ID,
+ });
+ },
+ failureCb: (err?: string) => {
+ toast.error(err || "Connection deletion failed!", {
+ id: CONNECTIONS_TOAST_ID,
+ });
+ },
+ });
+ }, [data]);
+
+ const handleYes = () => {
+ setAskConfirmation(false);
+ };
+
+ const handleNo = () => {
+ setSelectedPlatform(null);
+ setAskConfirmation(false);
+ setIsDeletionConfirm(false);
+ };
+
+ const onClickPlatform: MouseEventHandler<HTMLDivElement> = (ev) => {
+ const { platform } = (ev.currentTarget as HTMLDivElement).dataset;
+ if (platform) {
+ setSelectedPlatform(platform);
+ activeConnection.id && setAskConfirmation(true);
+ }
+ };
+
+ const onCloseSideover = () => {
+ setSelectedPlatform(null);
+ };
+
+ const onSuccesscb = () => {
+ fetchData();
+ setSelectedPlatform(null);
+ };
+
+ const startDeletion: MouseEventHandler<SVGElement> = (ev) => {
+ ev.stopPropagation();
+ setIsDeletionConfirm(true);
+ };
+
+ return (
+ <>
+ <div
+ className={`flex flex-wrap gap-10 mt-4 relative ${
+ isLoading || isDeleting ? "animate-pulse" : ""
+ }`}
+ >
+ {(isLoading || isDeleting) && (
+ <div className="absolute z-10 w-full h-full top-0 left-0" />
+ )}
+ {Object.keys(CONNECTIONS).map((connectionKey: string) => {
+ const connection =
+ CONNECTIONS[connectionKey as keyof typeof CONNECTIONS];
+ const isActive = activeConnection.platform === connection.platform;
+ return (
+ <div
+ key={connectionKey}
+ className={`bg-secondary h-20 shadow hover:shadow-md flex card w-64 relative shrink-0 cursor-pointer ${
+ isActive || !activeConnection.id
+ ? "rounded-b"
+ : "rounded grayscale hover:grayscale-0"
+ }`}
+ data-platform={connection.platform}
+ onClick={onClickPlatform}
+ >
+ <img
+ className="w-1/2 h-full rounded-l-sm p-3"
+ src={`/images/connections/${connection.image}`}
+ alt="Room Image"
+ />
+ <div className="w-full flex flex-col py-3">
+ <h3
+ className={`mb-1 font-medium flex-1 ${
+ isActive ? "text-primary" : "text-tertiary"
+ }`}
+ >
+ {connection.name}
+ </h3>
+ {isActive && (
+ <TrashIcon
+ className="absolute right-3 bottom-3 w-4 text-error"
+ onClick={startDeletion}
+ />
+ )}
+ </div>
+ {isActive && (
+ <div className="bg-primary px-3 py-1 flex items-center justify-between transition text-xs shrink-0 absolute top-0 -translate-y-full w-full left-0 text-white rounded-t">
+ Active
+ <CheckBadgeIcon className="w-4" />
+ </div>
+ )}
+ </div>
+ );
+ })}
+ </div>
+ {selectedPlatform && askConfirmation && (
+ <ConfirmationModal
+ title={
+ "This will create a new connection and delete the old one. Are you sure you want to proceed with a new connection?"
+ }
+ handleNo={handleNo}
+ handleYes={handleYes}
+ />
+ )}
+ {isDeletionConfirm && (
+ <ConfirmationModal handleNo={handleNo} handleYes={handleDelete} />
+ )}
+ {selectedPlatform && !askConfirmation && (
+ <AddConnections
+ platform={selectedPlatform}
+ onClose={onCloseSideover}
+ onSuccesscb={onSuccesscb}
+ />
+ )}
+ </>
+ );
+}
+
+export default function Connections() {
+ return (
+ <div className="flex flex-col w-full flex-1 overflow-auto">
+ <h2 className="text-xl font-bold">
+ Connect to your existing Observablity Platform
+ </h2>
+ <p className="text-base mb-5 text-tertiary/[0.8]">
+ Doku improves observability by effortlessly exporting processed LLM data
+ to your preferred observability platform. This enables developers to
+ consolidate all application-related data, including LLM usage
+ indicators, into a single platform, simplifying the visualisation and
+ measurement of the entire application ecosystem.
+ </p>
+ <ManageConnections />
+ </div>
+ );
+}
diff --git a/src/client/src/app/(playground)/requests/request-details.tsx b/src/client/src/app/(playground)/requests/request-details.tsx
index 38a6bb1e..34cf3884 100644
--- a/src/client/src/app/(playground)/requests/request-details.tsx
+++ b/src/client/src/app/(playground)/requests/request-details.tsx
@@ -186,6 +186,7 @@ export default function RequestDetails() {
<a
href={request.image}
target="_blank"
+ rel="noopener noreferrer"
className="flex items-center justify-center aspect-h-1 aspect-w-1 w-full overflow-hidden rounded-md bg-secondary/[0.3] lg:aspect-none lg:h-80 mt-4 group relative p-4 text-center text-tertiary/[0.5]"
>
<Image
diff --git a/src/client/src/app/api/connections/[id]/route.ts b/src/client/src/app/api/connections/[id]/route.ts
new file mode 100644
index 00000000..5920f0e1
--- /dev/null
+++ b/src/client/src/app/api/connections/[id]/route.ts
@@ -0,0 +1,11 @@
+import { deleteConnection } from "@/lib/doku/connection";
+
+export async function DELETE(_: Request, context: any) {
+ const { id } = context.params;
+ const resp: any = await deleteConnection(id);
+ if (resp?.err)
+ return Response.json(resp.err || "Server error!", {
+ status: 400,
+ });
+ return Response.json(resp);
+}
diff --git a/src/client/src/app/api/connections/route.ts b/src/client/src/app/api/connections/route.ts
new file mode 100644
index 00000000..57536d4d
--- /dev/null
+++ b/src/client/src/app/api/connections/route.ts
@@ -0,0 +1,22 @@
+import { createConnection, getConnection } from "@/lib/doku/connection";
+
+export async function GET() {
+ const { err, data }: any = await getConnection();
+ if (err)
+ return Response.json(err, {
+ status: 400,
+ });
+ return Response.json(data);
+}
+
+export async function POST(request: Request) {
+ const formData = await request.json();
+
+ const { err, data }: any = await createConnection(formData);
+ if (err)
+ return Response.json(err, {
+ status: 400,
+ });
+
+ return Response.json(data);
+}
diff --git a/src/client/src/components/(landing-page)/components/footer.tsx b/src/client/src/components/(landing-page)/components/footer.tsx
index df73e4ba..4eecd2a3 100644
--- a/src/client/src/components/(landing-page)/components/footer.tsx
+++ b/src/client/src/components/(landing-page)/components/footer.tsx
@@ -56,6 +56,7 @@ export default function Footer() {
href="https://join.slack.com/t/dokulabs/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ"
className="text-tertiary hover:text-tertiary dark:hover:text-white ms-5"
target="_blank"
+ rel="noopener"
>
<svg viewBox="0 0 2447.6 2452.5" className="w-4 h-4">
<g clipRule="evenodd" fillRule="evenodd">
@@ -83,6 +84,7 @@ export default function Footer() {
href="https://twitter.com/doku_labs"
className="text-tertiary hover:text-tertiary dark:hover:text-white ms-5"
target="_blank"
+ rel="noopener"
>
<svg
xmlns="http://www.w3.org/2000/svg"
@@ -101,6 +103,7 @@ export default function Footer() {
href="https://github.com/dokulabs"
className="text-tertiary hover:text-tertiary dark:hover:text-white ms-5"
target="_blank"
+ rel="noopener"
>
<svg
className="w-4 h-4"
diff --git a/src/client/src/components/(playground)/sidebar.tsx b/src/client/src/components/(playground)/sidebar.tsx
index 4278e3f1..5caf330e 100644
--- a/src/client/src/components/(playground)/sidebar.tsx
+++ b/src/client/src/components/(playground)/sidebar.tsx
@@ -10,7 +10,7 @@ import {
} from "@heroicons/react/24/solid";
import Image from "next/image";
import { usePathname } from "next/navigation";
-import { WrenchScrewdriverIcon } from "@heroicons/react/24/outline";
+import { LinkIcon, WrenchScrewdriverIcon } from "@heroicons/react/24/outline";
type SidebarItemProps = {
className?: string;
@@ -46,6 +46,11 @@ const SIDEBAR_ITEMS: SidebarItemProps[] = [
text: "API keys",
link: "/api-keys",
},
+ {
+ leftIcon: <LinkIcon className={ICON_CLASSES} />,
+ text: "Connections",
+ link: "/connections",
+ },
{
leftIcon: <WrenchScrewdriverIcon className={ICON_CLASSES} />,
text: "Settings",
@@ -115,7 +120,7 @@ export default function Sidebar() {
/>
</div>
<div className="w-full margin-y-2" />
- <ul className="flex-1 pt-2 space-y-2">
+ <ul className="flex-1 pt-2 text-sm">
{SIDEBAR_ITEMS.map((item, index) => (
<li key={`sidebar-${index}`}>
<SidebarItem
@@ -129,7 +134,7 @@ export default function Sidebar() {
</li>
))}
</ul>
- <ul className="shrink-0 space-y-2 bg-secondary/[0.9]">
+ <ul className="shrink-0 bg-secondary/[0.9]">
{SIDEBAR_BOTTOM_ITEMS.map((item, index) => (
<li key={`sidebar-${index}`}>
<SidebarItem
diff --git a/src/client/src/components/common/confirmation-modal.tsx b/src/client/src/components/common/confirmation-modal.tsx
index 1023d2d8..face662d 100644
--- a/src/client/src/components/common/confirmation-modal.tsx
+++ b/src/client/src/components/common/confirmation-modal.tsx
@@ -1,6 +1,7 @@
import { XCircleIcon } from "@heroicons/react/24/outline";
type ConfirmationModalProps = {
+ title?: string;
handleYes: () => void;
handleNo: () => void;
isUpdating?: boolean;
@@ -9,7 +10,7 @@ type ConfirmationModalProps = {
export default function ConfirmationModal(props: ConfirmationModalProps) {
return (
<div className="overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 flex justify-center items-center w-full h-full bg-tertiary/[.6]">
- <div className="relative p-4 w-full max-w-md h-full md:h-auto">
+ <div className="relative p-6 w-full max-w-lg h-full md:h-auto">
<div className="relative p-4 text-center bg-white rounded sm:p-5">
<button
type="button"
@@ -19,7 +20,7 @@ export default function ConfirmationModal(props: ConfirmationModalProps) {
<XCircleIcon className="w-5" />
</button>
<p className="mb-4 text-tertiary text-left">
- Are you sure you want to delete this item?
+ {props.title || "Are you sure you want to delete this item?"}
</p>
<div className="flex items-center space-x-4 w-full">
<button
diff --git a/src/client/src/components/common/form-builder.tsx b/src/client/src/components/common/form-builder.tsx
index d1961046..4b64c15e 100644
--- a/src/client/src/components/common/form-builder.tsx
+++ b/src/client/src/components/common/form-builder.tsx
@@ -51,7 +51,7 @@ const FormBuilder = ({
submitButtonText,
}: {
fields: FieldProps[];
- heading: string;
+ heading?: string;
isLoading?: boolean;
onSubmit: FormEventHandler<HTMLFormElement>;
submitButtonText: string;
@@ -62,15 +62,17 @@ const FormBuilder = ({
onSubmit={isLoading ? noop : onSubmit}
>
<div className="flex flex-col relative flex-1 overflow-y-auto">
- <h2 className="text-base font-semibold px-5 pt-3 text-tertiary sticky top-0 bg-white">
- {heading}
- </h2>
+ {heading && (
+ <h2 className="text-base font-semibold px-5 pt-3 text-tertiary sticky top-0 bg-white">
+ {heading}
+ </h2>
+ )}
- <div className="flex flex-col relative flex-1 overflow-y-auto px-5 pb-3">
- {fields.map((field, index) => (
- <FormField key={index} {...field} />
- ))}
- </div>
+ <div className="flex flex-col relative flex-1 overflow-y-auto px-5 pb-3">
+ {fields.map((field, index) => (
+ <FormField key={index} {...field} />
+ ))}
+ </div>
<div className="mt-6 flex items-center justify-end border-t border-secondary w-full py-2 gap-3">
<button
type="submit"
diff --git a/src/client/src/lib/doku/common.ts b/src/client/src/lib/doku/common.ts
index 3c305b43..d13ed2ec 100644
--- a/src/client/src/lib/doku/common.ts
+++ b/src/client/src/lib/doku/common.ts
@@ -11,6 +11,7 @@ import {
export const DATA_TABLE_NAME = "DOKU_LLM_DATA";
export const API_KEY_TABLE_NAME = "DOKU_APIKEYS";
+export const CONNECTION_TABLE_NAME = "DOKU_CONNECTIONS";
export const RESTRICTED_API_KEY_DELETION_NAMES = ["doku-client-internal"];
export type TimeLimit = {
@@ -69,8 +70,8 @@ export async function dataCollector(
);
if (result) {
- const data = await result?.json();
- return { data };
+ const [err, data] = await asaw(result?.json());
+ return { err, data };
}
} else if (clientQueryType === "insert") {
if (!table || !values) return { err: "No table specified!" };
diff --git a/src/client/src/lib/doku/connection.ts b/src/client/src/lib/doku/connection.ts
new file mode 100644
index 00000000..1695d9fb
--- /dev/null
+++ b/src/client/src/lib/doku/connection.ts
@@ -0,0 +1,48 @@
+import { validateConnectionRequest } from "@/utils/connection";
+import { CONNECTION_TABLE_NAME, dataCollector } from "./common";
+
+export async function getConnection() {
+ return await dataCollector({
+ query: `SELECT * from ${CONNECTION_TABLE_NAME}`,
+ });
+}
+
+export async function createConnection(values: any) {
+ const { err: deleteErr } = await dataCollector(
+ {
+ query: `DELETE from ${CONNECTION_TABLE_NAME} WHERE 1=1`,
+ },
+ "command"
+ );
+
+ if (deleteErr) {
+ return { err: deleteErr };
+ }
+
+ const { success, err: validationErr } = validateConnectionRequest(values);
+ if (!success) return { err: validationErr };
+
+ const { err } = await dataCollector(
+ {
+ table: CONNECTION_TABLE_NAME,
+ values: [values],
+ format: "JSONEachRow",
+ },
+ "insert"
+ );
+
+ if (err) {
+ return { err };
+ }
+
+ return await getConnection();
+}
+
+export async function deleteConnection(id: string) {
+ return dataCollector(
+ {
+ query: `DELETE FROM ${CONNECTION_TABLE_NAME} WHERE id = '${id}'`,
+ },
+ "command"
+ );
+}
diff --git a/src/client/src/middleware.ts b/src/client/src/middleware.ts
index 26d19226..6012d78c 100644
--- a/src/client/src/middleware.ts
+++ b/src/client/src/middleware.ts
@@ -66,5 +66,6 @@ export const config = {
"/api-keys",
"/requests",
"/settings",
+ "/connections",
],
};
diff --git a/src/client/src/utils/connection.ts b/src/client/src/utils/connection.ts
new file mode 100644
index 00000000..b3ead4e1
--- /dev/null
+++ b/src/client/src/utils/connection.ts
@@ -0,0 +1,76 @@
+import { isEmpty } from "lodash";
+
+export const CONNECTION_PLATFORM = {
+ grafana: "grafana",
+ datadog: "datadog",
+ newrelic: "newrelic",
+ dynatrace: "dynatrace",
+ signoz: "signoz",
+};
+
+export type CONNECTION_PLATFORM_TYPE = keyof typeof CONNECTION_PLATFORM;
+
+export type CONNECTION_PARAMS = {
+ platform: CONNECTION_PLATFORM_TYPE;
+ apiKey: string;
+ logsUsername?: string;
+ logsUrl?: string;
+ metricsUsername?: string;
+ metricsUrl?: string;
+};
+
+export const validateConnectionRequest = (
+ request: CONNECTION_PARAMS
+): { success: boolean; err?: string } => {
+ switch (request.platform) {
+ case "grafana":
+ case "datadog":
+ case "newrelic":
+ case "dynatrace":
+ if (isEmpty(request.apiKey))
+ return {
+ success: false,
+ err: "Api key missing!",
+ };
+ if (isEmpty(request.metricsUsername))
+ return {
+ success: false,
+ err: "Metrics username missing!",
+ };
+ if (isEmpty(request.metricsUrl))
+ return {
+ success: false,
+ err: "Metrics url missing!",
+ };
+ if (isEmpty(request.logsUsername))
+ return {
+ success: false,
+ err: "Logs username missing!",
+ };
+ if (isEmpty(request.logsUrl))
+ return {
+ success: false,
+ err: "Logs url missing!",
+ };
+
+ return { success: true };
+ case "signoz":
+ if (isEmpty(request.apiKey))
+ return {
+ success: false,
+ err: "Api key missing!",
+ };
+ if (isEmpty(request.logsUrl))
+ return {
+ success: false,
+ err: "Logs url missing!",
+ };
+
+ return { success: true };
+ default:
+ return {
+ success: false,
+ err: "No other platform is supported for now!",
+ };
+ }
+};