@@ -76,26 +76,22 @@ const Bytes: React.FC = () => {
7676 const now = React . useMemo ( ( ) => new Date ( ) , [ ] ) ;
7777 const { selectedCluster } = useCluster ( ) ;
7878
79- // Fetch metrics with cluster filtering
79+ // Fetch metrics (instance-level metrics don't need cluster filtering)
8080 const { data : readData , loading : readLoading } = useFetchMetrics (
8181 'compute.googleapis.com/instance/disk/read_bytes_count' ,
8282 rangeToMinutes [ range ] ,
83- selectedCluster ,
8483 ) ;
8584 const { data : writeData , loading : writeLoading } = useFetchMetrics (
8685 'compute.googleapis.com/instance/disk/write_bytes_count' ,
8786 rangeToMinutes [ range ] ,
88- selectedCluster ,
8987 ) ;
9088 const { data : receivedData , loading : receivedLoading } = useFetchMetrics (
9189 'compute.googleapis.com/instance/network/received_bytes_count' ,
9290 rangeToMinutes [ range ] ,
93- selectedCluster ,
9491 ) ;
9592 const { data : sentData , loading : sentLoading } = useFetchMetrics (
9693 'compute.googleapis.com/instance/network/sent_bytes_count' ,
9794 rangeToMinutes [ range ] ,
98- selectedCluster ,
9995 ) ;
10096
10197 // Combine and transform data
@@ -115,10 +111,9 @@ const Bytes: React.FC = () => {
115111 }
116112 > ( ) ;
117113
118- // Helper function to calculate Kib/s
119- const calculateKibPerSecond = ( bytes : number , intervalSeconds : number ) => {
120- if ( intervalSeconds <= 0 ) return 0 ;
121- return bytes / 1024 / intervalSeconds ; // Convert bytes to Kibibytes and then to per second
114+ // Helper function to convert bytes to KiB (since GCP already provides rate data)
115+ const convertBytesToKib = ( bytes : number ) => {
116+ return bytes / 1024 ; // Convert bytes to Kibibytes
122117 } ;
123118
124119 // Process disk read data
@@ -127,11 +122,8 @@ const Bytes: React.FC = () => {
127122 Number ( point . interval ?. endTime ?. seconds ) * 1000 ,
128123 ) ;
129124 const dateKey = timestamp . toISOString ( ) ;
130- const bytes = Number ( point . value ?. int64Value ?? 0 ) ;
131- const intervalSeconds =
132- Number ( point . interval ?. endTime ?. seconds ) -
133- Number ( point . interval ?. startTime ?. seconds ) || 60 ;
134- const value = calculateKibPerSecond ( bytes , intervalSeconds ) ;
125+ const bytes = Number ( point . value ?. doubleValue ?? point . value ?. int64Value ?? 0 ) ;
126+ const value = convertBytesToKib ( bytes ) ;
135127
136128 if ( ! dataMap . has ( dateKey ) ) {
137129 dataMap . set ( dateKey , {
@@ -158,11 +150,8 @@ const Bytes: React.FC = () => {
158150 Number ( point . interval ?. endTime ?. seconds ) * 1000 ,
159151 ) ;
160152 const dateKey = timestamp . toISOString ( ) ;
161- const bytes = Number ( point . value ?. int64Value ?? 0 ) ;
162- const intervalSeconds =
163- Number ( point . interval ?. endTime ?. seconds ) -
164- Number ( point . interval ?. startTime ?. seconds ) || 60 ;
165- const value = calculateKibPerSecond ( bytes , intervalSeconds ) ;
153+ const bytes = Number ( point . value ?. doubleValue ?? point . value ?. int64Value ?? 0 ) ;
154+ const value = convertBytesToKib ( bytes ) ;
166155
167156 if ( ! dataMap . has ( dateKey ) ) {
168157 dataMap . set ( dateKey , {
@@ -189,11 +178,8 @@ const Bytes: React.FC = () => {
189178 Number ( point . interval ?. endTime ?. seconds ) * 1000 ,
190179 ) ;
191180 const dateKey = timestamp . toISOString ( ) ;
192- const bytes = Number ( point . value ?. int64Value ?? 0 ) ;
193- const intervalSeconds =
194- Number ( point . interval ?. endTime ?. seconds ) -
195- Number ( point . interval ?. startTime ?. seconds ) || 60 ;
196- const value = calculateKibPerSecond ( bytes , intervalSeconds ) ;
181+ const bytes = Number ( point . value ?. doubleValue ?? point . value ?. int64Value ?? 0 ) ;
182+ const value = convertBytesToKib ( bytes ) ;
197183 if ( ! dataMap . has ( dateKey ) ) {
198184 dataMap . set ( dateKey , {
199185 date : dateKey ,
@@ -219,11 +205,8 @@ const Bytes: React.FC = () => {
219205 Number ( point . interval ?. endTime ?. seconds ) * 1000 ,
220206 ) ;
221207 const dateKey = timestamp . toISOString ( ) ;
222- const bytes = Number ( point . value ?. int64Value ?? 0 ) ;
223- const intervalSeconds =
224- Number ( point . interval ?. endTime ?. seconds ) -
225- Number ( point . interval ?. startTime ?. seconds ) || 60 ;
226- const value = calculateKibPerSecond ( bytes , intervalSeconds ) ;
208+ const bytes = Number ( point . value ?. doubleValue ?? point . value ?. int64Value ?? 0 ) ;
209+ const value = convertBytesToKib ( bytes ) ;
227210
228211 if ( ! dataMap . has ( dateKey ) ) {
229212 dataMap . set ( dateKey , {
0 commit comments