Skip to content

Commit

Permalink
updated to handle multiple httpvals in one request
Browse files Browse the repository at this point in the history
Signed-off-by: Dhruv-J <dhruvj@vmware.com>
  • Loading branch information
Dhruv-J committed Sep 27, 2023
1 parent 8fce175 commit 2482c26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build/charts/theia/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Kubernetes: `>= 1.16.0-0`
| grafana.enable | bool | `true` | Determine whether to install Grafana. It is used as a data visualization and monitoring tool. |
| grafana.homeDashboard | string | `"homepage.json"` | Default home dashboard. |
| grafana.image | object | `{"pullPolicy":"IfNotPresent","repository":"projects.registry.vmware.com/antrea/theia-grafana","tag":"8.3.3"}` | Container image used by Grafana. |
| grafana.installPlugins | list | `["https://downloads.antrea.io/artifacts/grafana-custom-plugins/theia-grafana-sankey-plugin-1.0.2.zip;theia-grafana-sankey-plugin","https://downloads.antrea.io/artifacts/grafana-custom-plugins/theia-grafana-chord-plugin-1.0.1.zip;theia-grafana-chord-plugin","https://downloads.antrea.io/artifacts/grafana-custom-plugins/theia-grafana-dependency-plugin-1.0.2.zip;theia-grafana-dependency-plugin","grafana-clickhouse-datasource 1.0.1"]` | Grafana plugins to install. |
| grafana.installPlugins | list | `["https://downloads.antrea.io/artifacts/grafana-custom-plugins/theia-grafana-sankey-plugin-1.0.2.zip;theia-grafana-sankey-plugin","https://downloads.antrea.io/artifacts/grafana-custom-plugins/theia-grafana-chord-plugin-1.0.1.zip;theia-grafana-chord-plugin","https://github.com/Dhruv-J/grafana-dependency-plugin/archive/refs/tags/v0.zip;theia-grafana-dependency-plugin","grafana-clickhouse-datasource 1.0.1"]` | Grafana plugins to install. |
| grafana.log | object | `{"daily_rotate":"true","level":"info","log_rotate":"true","max_days":"7","max_lines":"1000000","max_size_shift":"27","mode":"console file"}` | Grafana logging options. |
| grafana.log.daily_rotate | string | `"true"` | Enable daily rotation of files, valid options are false or true. Default is true. Only applicable when “file” used in [log] mode. |
| grafana.log.level | string | `"info"` | Logging level. Options are “debug”, “info”, “warn”, “error”, and “critical”. Default is info. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,6 @@ export const DependencyPanel: React.FC<Props> = ({ options, data, width, height
}

function layerSevenGraph() {
interface HTTPInfo {
hostname: string;
url: string;
http_user_agent: string;
http_content_type: string;
http_method: string;
protocol: string;
status: number;
length: number
}

function getColorFromStatus(httpStatus: string) {
// colors that correspond to each of the types of http response code; i.e. 4xx and 5xx codes return red to symbolize errors
const colors = ['orange', 'green', 'blue', 'red', 'red'];
Expand All @@ -162,6 +151,7 @@ export const DependencyPanel: React.FC<Props> = ({ options, data, width, height
return colors[statusType-1];
}

let ctr = 0;
for (let i = 0; i < frame.length; i++) {
const sourcePodName = sourcePodNames?.values.get(i);
const destinationPodName = destinationPodNames?.values.get(i);
Expand All @@ -171,24 +161,26 @@ export const DependencyPanel: React.FC<Props> = ({ options, data, width, height
const destinationPort = destinationTransportPorts?.values.get(i);
const httpVals = httpValsList?.values.get(i);

let httpValsTrimmed = httpVals.substring(5, httpVals.length-1);
let frameHttpInfo: HTTPInfo = JSON.parse(httpValsTrimmed);
let graphLine = '';
if (sourcePodName !== '') {
graphLine = sourcePodName;
} else {
graphLine = sourceIP + ':' + sourcePort;
}
graphLine = graphLine + ' --' + frameHttpInfo.length + '--> ';
if (destinationPodName !== '') {
graphLine = graphLine + destinationPodName;
} else {
graphLine = graphLine + destinationIP + ':' + destinationPort;
let httpValsJSON = JSON.parse(httpVals);
for (const txId in httpValsJSON) {
let graphLine = '';
if (sourcePodName !== '') {
graphLine = sourcePodName;
} else {
graphLine = sourceIP + ':' + sourcePort;
}
graphLine = graphLine + ' --' + httpValsJSON[txId].length + '--> ';
if (destinationPodName !== '') {
graphLine = graphLine + destinationPodName;
} else {
graphLine = graphLine + destinationIP + ':' + destinationPort;
}
// graphLine = sourceIP + ':' + sourcePort + ' --' + frameHttpInfo.ContentLength + '--> ' + destinationIP + ':' + destinationPort + '\n';
graphString = graphString + graphLine + '\n';
let styleLine = 'linkStyle ' + ctr + ' stroke: ' + getColorFromStatus(httpValsJSON.status+'') + '\n';
styleString = styleString + styleLine;
ctr += 1;
}
// graphLine = sourceIP + ':' + sourcePort + ' --' + frameHttpInfo.ContentLength + '--> ' + destinationIP + ':' + destinationPort + '\n';
graphString = graphString + graphLine + '\n';
let styleLine = 'linkStyle ' + i + ' stroke: ' + getColorFromStatus(frameHttpInfo.status+'') + '\n';
styleString = styleString + styleLine;
}

graphString = graphString + styleString;
Expand Down

0 comments on commit 2482c26

Please sign in to comment.