Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
strings.concat
strings.concat(a, b, c, ...)
Deskripsi
Menampilkan gabungan dari sejumlah item yang tidak terbatas, yang masing-masing dapat berupa string, bilangan bulat, atau float.
Jika ada argumen yang merupakan kolom peristiwa, atribut harus berasal dari peristiwa yang sama.
Jenis data parameter
STRING
, FLOAT
, INT
Jenis hasil yang ditampilkan
STRING
Contoh kode
Contoh 1
Contoh berikut menyertakan variabel string dan variabel bilangan bulat sebagai
argumen. principal.hostname
dan principal.port
berasal dari
peristiwa yang sama, $e
, dan digabungkan untuk menampilkan string.
"google:80" = strings.concat($e.principal.hostname, ":", $e.principal.port)
Contoh 2
Contoh berikut menyertakan variabel string dan literal string sebagai argumen.
"google-test" = strings.concat($e.principal.hostname, "-test") // Matches the event when $e.principal.hostname = "google"
Contoh 3
Contoh berikut menyertakan variabel string dan literal float sebagai argumen.
Jika direpresentasikan sebagai string, float yang merupakan bilangan bulat diformat tanpa
titik desimal (misalnya, 1.0 direpresentasikan sebagai "1"). Selain itu,
float yang melebihi enam belas digit desimal akan dipangkas menjadi enam belas
tempat desimal.
"google2.5" = strings.concat($e.principal.hostname, 2.5)
Contoh 4
Contoh berikut menyertakan variabel string, literal string,
variabel bilangan bulat, dan literal float sebagai argumen. Semua variabel berasal dari
peristiwa yang sama, $e
, dan digabungkan dengan literal untuk menampilkan string.
"google-test802.5" = strings.concat($e.principal.hostname, "-test", $e.principal.port, 2.5)
Contoh 5
Contoh berikut mencoba menggabungkan principal.port dari peristiwa $e1
,
dengan principal.hostname
dari peristiwa $e2
. Hal ini akan menampilkan error compiler
karena argumennya adalah variabel peristiwa yang berbeda.
// Will not compile
"test" = strings.concat($e1.principal.port, $e2.principal.hostname)
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-29 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-29 UTC."],[[["\u003cp\u003e\u003ccode\u003estrings.concat\u003c/code\u003e combines multiple strings, integers, or floats into a single string, supporting an unlimited number of arguments.\u003c/p\u003e\n"],["\u003cp\u003eWhen using event fields as arguments within \u003ccode\u003estrings.concat\u003c/code\u003e, all fields must be attributes originating from the same event.\u003c/p\u003e\n"],["\u003cp\u003eThe function supports various data types, including \u003ccode\u003eSTRING\u003c/code\u003e, \u003ccode\u003eFLOAT\u003c/code\u003e, and \u003ccode\u003eINT\u003c/code\u003e, and returns a \u003ccode\u003eSTRING\u003c/code\u003e value after concatenation.\u003c/p\u003e\n"],["\u003cp\u003eFloat numbers in \u003ccode\u003estrings.concat\u003c/code\u003e are formatted as whole numbers without a decimal point when they are whole numbers, and they are truncated to the sixteenth decimal place if exceeding that value.\u003c/p\u003e\n"],["\u003cp\u003eAttempting to concatenate event fields that belong to different events will result in a compiler error.\u003c/p\u003e\n"]]],[],null,["### strings.concat\n\nSupported in: \n[Rules](/chronicle/docs/detection/default-rules) [Search](/chronicle/docs/investigation/udm-search) \n\n strings.concat(a, b, c, ...)\n\n#### Description\n\nReturns the concatenation of an unlimited number of items, each of which can be\na string, integer, or float.\n\nIf any arguments are event fields, the attributes must be from the same event.\n\n#### Param data types\n\n`STRING`, `FLOAT`, `INT`\n\n#### Return type\n\n`STRING`\n\n#### Code samples\n\n##### Example 1\n\nThe following example includes a string variable and integer variable as\narguments. Both `principal.hostname` and `principal.port` are from the same\nevent, `$e`, and are concatenated to return a string. \n\n \"google:80\" = strings.concat($e.principal.hostname, \":\", $e.principal.port)\n\n##### Example 2\n\nThe following example includes a string variable and string literal as arguments. \n\n \"google-test\" = strings.concat($e.principal.hostname, \"-test\") // Matches the event when $e.principal.hostname = \"google\"\n\n##### Example 3\n\nThe following example includes a string variable and float literal as arguments.\nWhen represented as strings, floats that are whole numbers are formatted without\nthe decimal point (for example, 1.0 is represented as \"1\"). Additionally,\nfloats that exceed sixteen decimal digits are truncated to the sixteenth decimal\nplace. \n\n \"google2.5\" = strings.concat($e.principal.hostname, 2.5)\n\n##### Example 4\n\nThe following example includes a string variable, string literal,\ninteger variable, and float literal as arguments. All variables are from the\nsame event, `$e`, and are concatenated with the literals to return a string. \n\n \"google-test802.5\" = strings.concat($e.principal.hostname, \"-test\", $e.principal.port, 2.5)\n\n##### Example 5\n\nThe following example attempts to concatenate principal.port from event `$e1`,\nwith `principal.hostname` from event `$e2`. It will return a compiler error\nbecause the arguments are different event variables. \n\n // Will not compile\n \"test\" = strings.concat($e1.principal.port, $e2.principal.hostname)"]]