The invention relates to a porous optical fiber for the detection of an analyte in a fluid by optical probing. The optical fiber has a first end and a second end opposite to the first end, as seen in a longitudinal direction, and a circumferential surface delimiting the optical fiber in radial directions perpendicular to the longitudinal direction. The optical fiber comprises a core adapted for supporting at least one optical mode propagating in the longitudinal direction, the core having a circumferential interface delimiting the core in the radial directions. The optical fiber further comprises pores penetrating from an opening at the circumferential surface through the circumferential interface into the core of the optical fiber, wherein a cross-sectional dimension of the openings is dimensioned so as to prevent a particulate fraction of the fluid from entering the pores, while allowing the analyte to enter the pores.