rs_workflows/operation/quota_monitoring_flow.md
OBS logs ingestion flow implementation
batch_insert(conn, rows)
Insert a batch of rows using execute_values for high performance.
Source code in docs/rs-client-libraries/rs_workflows/operation/quota_monitoring_flow.py
150 151 152 153 154 155 156 157 158 | |
clean_obs_logs(retention_days=DEFAULT_MAX_DAYS, env=FlowEnvArgs(owner_id='operator-quota'))
async
Purge the table s3_access_log. Args: retention_days : number of days of retention of log information from OBS env (FlowEnvArgs, optional): Flow environment arguments containing owner_id and other configuration parameters. Returns: None Raises: psycopg2.Error: If database connection or insertion operations fail.
Source code in docs/rs-client-libraries/rs_workflows/operation/quota_monitoring_flow.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
collect_obs_logs(platform='rspython-ops', max_files=DEFAULT_MAX_FILES, threshold_minute=DEFAULT_AGE_THRESHOLD, env=FlowEnvArgs(owner_id='operator-quota'))
async
Collect and process OVH quota monitoring logs from S3 and insert them into a PostgreSQL database. This async function retrieves observability logs from an S3 bucket, parses them, and performs batch insertions into a Postgres quota database. Args: platform : platform name, will be the prefix of the bucket name max_files : number maximum of files read from the bucket threshold_minute : this threshold is set to avoid reading and deleting a log file whereas it is filled env (FlowEnvArgs, optional): Flow environment arguments containing owner_id and other configuration parameters. Returns: None Raises: psycopg2.Error: If database connection or insertion operations fail. KeyError: If required environment variables are not set. Exception: If S3 operations or log parsing encounters errors. Environment Variables Required: - POSTGRES_QUOTA_USER: PostgreSQL username for quota database - POSTGRES_QUOTA_PASSWORD: PostgreSQL password - POSTGRES_HOST: PostgreSQL host address - POSTGRES_PORT: PostgreSQL port number - S3_QUOTA_ENDPOINT: S3 endpoint URL to access the bucket with logs - S3_QUOTA_ACCESSKEY: S3 access key ID to access the bucket with logs - S3_QUOTA_SECRETKEY: S3 secret access key to access the bucket with logs - S3_QUOTA_REGION: S3 region name to access the bucket with logs
Source code in docs/rs-client-libraries/rs_workflows/operation/quota_monitoring_flow.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
list_recent_files(s3, platform, max_files, threshold_minute)
List up to 'max_files' files older than 'threshold_minute'.
Source code in docs/rs-client-libraries/rs_workflows/operation/quota_monitoring_flow.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
parse_log_line(line)
Parse a single OVH/S3 access log line into a list of fields.
Source code in docs/rs-client-libraries/rs_workflows/operation/quota_monitoring_flow.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
read_object(s3, platform, key)
Stream-read an S3 object line by line.
Source code in docs/rs-client-libraries/rs_workflows/operation/quota_monitoring_flow.py
71 72 73 74 75 76 77 78 79 80 81 82 | |