Skip to content

Commit

Permalink
prometheus importer line validation
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Sep 13, 2021
1 parent 931a280 commit 23b39d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Metrics/Importer/PrometheusImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public function fromString(string $string, string $prefix = ''): self

private function parseInfoLine(string $line, string $prefix)
{
[$_, $type, $nick, $value] = explode(' ', $line, 4);
$parts = explode(' ', $line, 4);
if (count($parts) < 4) {
return null;
}

[$_, $type, $nick, $value] = $parts;
if ($prefix && strpos($nick, $prefix) === 0) {
$nick = substr($nick, strlen($prefix));
}
Expand Down

0 comments on commit 23b39d5

Please sign in to comment.